lasthourcloud/app/Http/Livewire/Profile/Form.php

41 lines
816 B
PHP
Raw Normal View History

2023-05-22 20:30:33 +00:00
<?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',
];
2023-06-16 10:35:40 +00:00
protected $validationAttributes = [
'name' => 'name',
];
2023-05-22 20:30:33 +00:00
public function mount()
{
$this->userId = auth()->user()->id;
$this->name = auth()->user()->name;
$this->email = auth()->user()->email;
}
2023-05-22 20:30:33 +00:00
public function submit()
{
try {
$this->validate();
User::where('id', $this->userId)->update([
'name' => $this->name,
]);
2023-06-09 13:55:21 +00:00
} catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this);
2023-05-22 20:30:33 +00:00
}
}
}