wip: migrate to livewire 3
This commit is contained in:
35
app/Livewire/Team/Form.php
Normal file
35
app/Livewire/Team/Form.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Team;
|
||||
|
||||
use App\Models\Team;
|
||||
use Livewire\Component;
|
||||
|
||||
class Form extends Component
|
||||
{
|
||||
public Team $team;
|
||||
protected $rules = [
|
||||
'team.name' => 'required|min:3|max:255',
|
||||
'team.description' => 'nullable|min:3|max:255',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'team.name' => 'name',
|
||||
'team.description' => 'description',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->team = currentTeam();
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
try {
|
||||
$this->team->save();
|
||||
refreshSession();
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user