lasthourcloud/app/Http/Livewire/Profile/Form.php
2023-08-08 11:51:36 +02:00

41 lines
816 B
PHP

<?php
namespace App\Http\Livewire\Profile;
use App\Models\User;
use Livewire\Component;
class Form extends Component
{
public int $userId;
public string $name;
public string $email;
protected $rules = [
'name' => 'required',
];
protected $validationAttributes = [
'name' => 'name',
];
public function mount()
{
$this->userId = auth()->user()->id;
$this->name = auth()->user()->name;
$this->email = auth()->user()->email;
}
public function submit()
{
try {
$this->validate();
User::where('id', $this->userId)->update([
'name' => $this->name,
]);
} catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this);
}
}
}