48 lines
928 B
Plaintext
48 lines
928 B
Plaintext
<?php
|
|
|
|
namespace {{ namespace }};
|
|
|
|
use App\Models\{{ model }};
|
|
use Filament\Forms;
|
|
use Filament\Forms\Concerns\InteractsWithForms;
|
|
use Filament\Forms\Contracts\HasForms;
|
|
use Filament\Forms\Form;
|
|
use Livewire\Component;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
class {{ class }} extends Component implements HasForms
|
|
{
|
|
use InteractsWithForms;
|
|
|
|
public ?array $data = [];
|
|
|
|
public {{ modelClass }} $record;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->form->fill($this->record->attributesToArray());
|
|
}
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
{{ schema }}
|
|
])
|
|
->statePath('data')
|
|
->model($this->record);
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$data = $this->form->getState();
|
|
|
|
$this->record->update($data);
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('{{ view }}');
|
|
}
|
|
}
|