<?php
namespace App\Http\Livewire\Components\Administration;
use App\AdminSetting;
use Livewire\Component;
use Illuminate\Contracts\View\View;
use App\View\Components\AdminLayout;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Concerns\InteractsWithForms;
class EditAdminSettings extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public AdminSetting $record;
public function mount(): void
{
$this->record = AdminSetting::all()->first();
$this->form->fill($this->record->attributesToArray());
}
protected function getFormSchema(): array
{
return [
FileUpload::make('chairman_signature')
->image()
->enableOpen()
->enableDownload()
->preserveFilenames()
->disk('s3')
->directory('admin_settings/chairman_signature'),
];
}
public function edit(): void
{
$data = $this->form->getState();
$this->record->update($data);
}
protected function getFormModel(): AdminSetting
{
return $this->record;
}
protected function getFormStatePath(): string
{
return 'data';
}
public function render(): View
{
return view('livewire.components.administration.edit-admin-settings')
->layout(AdminLayout::class, [
'title' => 'Administrative settings',
]);
}
}