Desmond Njuguna
Call to a member function getForeignKeyName() on null
ListAdmissions.php
<?php
namespace App\Filament\Clusters\Patients\Resources\AdmissionResource\Pages;
use App\Filament\Clusters\Patients\Resources\AdmissionResource;
use App\Models\Configurations\Bed;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Support\Str;
class ListAdmissions extends ListRecords
{
protected static string $resource = AdmissionResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()
->icon('heroicon-o-squares-plus')
->label('Admit Patient')
->mutateFormDataUsing(function (array $data): array {
unset($data['ward_id']);
unset($data['room_id']);
$data['identification'] = Str::uuid();
return $data;
})
->after(function() {
$admission = $this->getRecord();
Bed::find($admission->bed_id)->booked();
}),
];
}
}
4 replies
multiple panels on single dashboard as tabs?
Hi Povilas, Panel switching is actually possible. There's a plugin for that, https://filamentphp.com/plugins/bezhansalleh-panel-switch, and you can also restrict who can and cannot use the panel swith, aither with roles or permissions
9 replies
My Resorce has Form I want to call it or inheritance this form in another palce
you can define a getForm static method in the corresponding model then call the form in any resource you want
Eg if you have a tag model and the resources, in the Tag model define a new methid like so
public static function getForm(): array
{
return [
TextInput::make('name')
->required()
->maxLength(255),
ColorPicker::make('color')
->required(),
];
}
Then in the tagresource form method do this
public static function form(Form $form): Form
{
return $form
->schema(Task::getForm());
}
I suppose you have a userresource and you might want to create a new tag without necessarily goung back to the tag resource, so in the tag form component of the userresource form method you can chain the method createOptionForm(App\Models\Tag::getForm()) and have it complete as so
Select::make('tags')
->relationship('tags', 'name',)
->multiple()
->searchable()
->preload()
->createOptionForm(Tag::getForm())
Hope this is what youre looking for
7 replies