mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-09 21:42:57 +00:00
40 lines
782 B
PHP
40 lines
782 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Pages;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
use Livewire\WithFileUploads;
|
|
|
|
class Profile extends Component
|
|
{
|
|
use WithFileUploads;
|
|
|
|
public User $user;
|
|
|
|
#[Validate('image|max:10240')]
|
|
public $avatar = null;
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.pages.profile')->title($this->user->name);
|
|
}
|
|
|
|
public function updated($name, $value)
|
|
{
|
|
if (Auth::id() != $this->user->id)
|
|
{
|
|
abort(401);
|
|
}
|
|
|
|
$this->validateOnly($name);
|
|
|
|
$this->user->avatarExt = $this->avatar->getClientOriginalExtension();
|
|
$this->user->save();
|
|
|
|
$this->avatar->storeAs('avatars', $this->user->id);
|
|
return $this->redirect("/profiles/{$this->user->id}");
|
|
}
|
|
}
|