mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
user profile updates
This commit is contained in:
parent
c7c621b086
commit
ea140671bc
9 changed files with 78 additions and 27 deletions
|
|
@ -19,11 +19,15 @@ class AuthController extends Controller
|
|||
|
||||
$authUser = User::updateOrCreate(
|
||||
[ 'email' => $user->getEmail() ],
|
||||
[ 'name' => $user->getName() ]
|
||||
);
|
||||
|
||||
if ($authUser)
|
||||
{
|
||||
if ($authUser->name == '')
|
||||
{
|
||||
$authUser->name = $user->getName();
|
||||
$authUser->save();
|
||||
}
|
||||
Auth::login($authUser);
|
||||
return redirect('/');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use Livewire\Component;
|
|||
|
||||
class Icon extends Component
|
||||
{
|
||||
public string $family = 'classic';
|
||||
public string $variant = 'light';
|
||||
public string $name = 'paw-simple';
|
||||
public string $label = '';
|
||||
public string $style = '';
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Livewire\Pages;
|
|||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
|
@ -14,15 +15,39 @@ class Profile extends Component
|
|||
|
||||
public User $user;
|
||||
|
||||
#[Validate('image|max:10240')]
|
||||
public $avatar = null;
|
||||
public string $name = '';
|
||||
|
||||
public function mount(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->name = $user->name;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.pages.profile')->title($this->user->name);
|
||||
}
|
||||
|
||||
public function updated()
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'avatar' => [
|
||||
'nullable',
|
||||
'image',
|
||||
'max:10240',
|
||||
],
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'min:2',
|
||||
'max:40',
|
||||
Rule::unique('users', 'name')->ignore($this->user),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function updated($name, $value)
|
||||
{
|
||||
if (Auth::id() != $this->user->id)
|
||||
{
|
||||
|
|
@ -31,10 +56,16 @@ class Profile extends Component
|
|||
|
||||
$this->validate();
|
||||
|
||||
$this->user->update([ $name => $value ]);
|
||||
|
||||
if (isset($this->avatar))
|
||||
{
|
||||
$this->user->avatarExt = $this->avatar->getClientOriginalExtension();
|
||||
$this->user->save();
|
||||
|
||||
$this->avatar->storeAs('avatars', $this->user->id);
|
||||
return $this->redirect("/profiles/{$this->user->id}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "photos",
|
||||
"name": "nyaabooru",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
<span class="wa-caption-l">© 2025 <a href="https://nyaastudios.io" target="_blank">NyaaStudios</a>; All rights reserved.</span>
|
||||
</div>
|
||||
<div class="wa-cluster wa-heading-m">
|
||||
<wa-icon-button family="brands" name="github" href="https://github.com/NyaaStudios/nyaabooru" target="_blank"></wa-icon-button>
|
||||
<a href="https://github.com/NyaaStudios/nyaabooru" class="wa-link-plain" target="_blank">
|
||||
<livewire:app.icon family="brands" name="github" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<wa-icon
|
||||
name="{{ $name }}"
|
||||
variant="light"
|
||||
family="{{ $family }}"
|
||||
variant="{{ $variant }}"
|
||||
label="{{ $label }}"
|
||||
fixed-width
|
||||
@isset($slot)
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@
|
|||
label="avatar for {{ $user->name }}"
|
||||
shape="{{ $shape }}"
|
||||
style="--size: {{ $size }}"
|
||||
></wa-avatar>
|
||||
>
|
||||
<livewire:app.icon name="user" slot="icon" size="2.5rem" />
|
||||
</wa-avatar>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
<article class="wa-stack nyaabooru-pfp">
|
||||
<a class="wa-frame wa-border-radius-l" style="inline-size: 15rem;" href="{{ url("/profiles/$user->id") }}" wire:navigate.hover>
|
||||
@if (\Illuminate\Support\Facades\Storage::has("avatars/$user->id"))
|
||||
<img src="{{ $user->getAvatarBase64() }}"/>
|
||||
@else
|
||||
<livewire:app.icon name="user" />
|
||||
@endif
|
||||
</a>
|
||||
<wa-card>
|
||||
<a class="wa-stack nyaabooru-pfp wa-link-plain" href="{{ url("/profiles/$user->id") }}" wire:navigate.hover>
|
||||
<div class="wa-frame wa-border-radius-l" style="inline-size: 10rem;" >
|
||||
<livewire:app.pfp :$user size="10rem" />
|
||||
</div>
|
||||
<div class="wa-stack wa-gap-3xs">
|
||||
<span class="wa-heading-s">{{ $user->name }}</span>
|
||||
<span class="wa-caption-m">Joined <wa-format-date value="{{ $user->created_at }}"></wa-format-date></span>
|
||||
</div>
|
||||
</article>
|
||||
</a>
|
||||
</wa-card>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<h2>User settings</h2>
|
||||
<form wire:submit>
|
||||
<wa-card>
|
||||
<div class="wa-stack wa-gap-l">
|
||||
<div class="wa-stack">
|
||||
<span class="wa-heading-m">Profile picture</span>
|
||||
<input type="file" wire:model.live="avatar" wire:loading.attr="disabled" />
|
||||
|
|
@ -30,6 +31,16 @@
|
|||
<span class="wa-caption-m">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<wa-divider></wa-divider>
|
||||
|
||||
<wa-input wire:model.live="name" label="Display name">
|
||||
<livewire:app.icon slot="start" name="user-tag" />
|
||||
</wa-input>
|
||||
@error('name')
|
||||
<span class="wa-caption-m">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
</wa-card>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue