49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Proclamatori;
|
|
|
|
use Livewire\Component;
|
|
use App\Models\Proclamatore;
|
|
|
|
class ProclamatoreCreate extends Component
|
|
{
|
|
public string $nome = '';
|
|
public string $cognome = '';
|
|
public bool $attivo = true;
|
|
|
|
protected function rules(): array
|
|
{
|
|
return [
|
|
'nome' => 'required|string|max:100',
|
|
'cognome' => 'required|string|max:100',
|
|
'attivo' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$this->validate();
|
|
|
|
$proclamatore = Proclamatore::create([
|
|
'nome' => $this->nome,
|
|
'cognome' => $this->cognome,
|
|
'attivo' => $this->attivo,
|
|
]);
|
|
|
|
activity()->causedBy(auth()->user())
|
|
->performedOn($proclamatore)
|
|
->log('created');
|
|
|
|
session()->flash('success', "Proclamatore {$proclamatore->nome_completo} creato.");
|
|
return $this->redirect(route('proclamatori.index'), navigate: true);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.proclamatori.proclamatore-form', [
|
|
'titolo' => 'Nuovo Proclamatore',
|
|
'btnLabel' => 'Crea Proclamatore',
|
|
]);
|
|
}
|
|
}
|