WiseWill
WiseWill
FFilament
Created by WiseWill on 3/14/2024 in #❓┊help
Caching Filament components
Referring to https://filamentphp.com/docs/3.x/panels/installation#caching-filament-components When I attempt
php artisan filament:cache-components
php artisan filament:cache-components
I get an error:
:~/Projects/Target/labman$ php artisan filament:cache-components

ERROR Command "filament:cache-components" is not defined. Did you mean one of these?

⇂ filament-excel:prune
⇂ filament:assets
⇂ filament:check-translations
⇂ filament:install
⇂ filament:upgrade
:~/Projects/Target/labman$ php artisan filament:cache-components

ERROR Command "filament:cache-components" is not defined. Did you mean one of these?

⇂ filament-excel:prune
⇂ filament:assets
⇂ filament:check-translations
⇂ filament:install
⇂ filament:upgrade
Has component caching been dropped? I am struggling with a bit of a lack of speed issue on a form which has a fair amount of Livewire and lots of components.
11 replies
FFilament
Created by WiseWill on 1/22/2024 in #❓┊help
Unauthenticated exception thrown instead of a login page
The path is set to '/' in the AppPanelProvider config. There is one panel. If I visit the base url of my app, e.g. http://labman (it is hosted on my local dev box, but I can provide a link to a staging site) while I am logged in, everything works as expected, i.e the dashboard is displayed. If I visit the login route, e.g. http://labman/login everything works as expected - I can log in, and I am redirected to the dashboard. However, if I visit the base domain while not logged in, I get an "Unauthenticated" error instead of the login page, which is what I expect. Flare link: https://flareapp.io/share/17WJD3DP
4 replies
FFilament
Created by WiseWill on 1/2/2024 in #❓┊help
Managing Relationships in the Form Builder
I have a pretty complex requirement related to relationships in a form. The form is in a RequisitionResource, and the Requisition has a Patient and a Guarantor. When a new requisition is being captured, the operator can use a searchable Select to find the patient, but if the patient cannot be found, a new one must be created without leaving the page. I am trying two approaches, a modal (https://bit.ly/3TMF42c) and a Section using the relationship() method (https://bit.ly/3TFG3B6). The modal works, and once a new patient is created it fills all the fields properly, including those in the Section. My problem here is that the modal is not the preferred approach for the client. If a patient is found in the Select and selected, the Section fields are populated, and can be edited - first prize. However, if a new patient is created using the same fields, the patient_id Select is not populated, and it really should be required(). Is there a way I can make the Section "live()" or something like that? The Guarantor is actually just another instance of a Patient model, and is often the same person. It is handled in the same way as the patient, with a Select, modal forms and a Section. A pair of buttons are provided to copy the patient_id to the gurantor_id, which both work, but the Section for the Guarantor is not populated when the patient_id is copied over. This is a problem, because the Guarantor form has a couple of fields which the patient doesn't have, which need to edited. The preference here is to stick to the relationship() method on the Section layout component and drop the modals altogether. I would really, really appreciate any help or suggestions offered.
Source code: https://gist.github.com/nettsite/ff80a0a061dfd49bfede1ee9c6afb227
2 replies
FFilament
Created by WiseWill on 1/1/2024 in #❓┊help
notification color
I have added the following code to position the notifications used in the panel builder forms , and it is perfect (I can't remember how I found out how to do this):
public function boot(): void
{
// All sorts of other stuff

// Set position for notifications in Filament pages
Notifications::alignment(Alignment::Center);
Notifications::verticalAlignment(VerticalAlignment::Center);
}
public function boot(): void
{
// All sorts of other stuff

// Set position for notifications in Filament pages
Notifications::alignment(Alignment::Center);
Notifications::verticalAlignment(VerticalAlignment::Center);
}
The notifications are a bit subtle for my use case. Is there a way to do something similar to change the notification colours and / or backgrounds for create and edit pages?
4 replies
FFilament
Created by WiseWill on 12/21/2023 in #❓┊help
Updating fields in a Section when a Select is changed based on a relationship.
For context, this is part of a laboratory system. A doctor completes a requisition, which is captured into the system. The requisition belongs to a patient:
class Requisition extends Model implements Auditable
{
public function patient(): BelongsTo
{
return $this->belongsTo(Patient::class);
}
}
class Requisition extends Model implements Auditable
{
public function patient(): BelongsTo
{
return $this->belongsTo(Patient::class);
}
}
A patient has many requisitions:
class Patient extends Model implements Auditable
{
public function requisition(): HasMany
{
return $this->hasMany(Requisition::class);
}
}
class Patient extends Model implements Auditable
{
public function requisition(): HasMany
{
return $this->hasMany(Requisition::class);
}
}
I need the requisition creation form to be able to select a patient, or create a new one if it exists. This works:
Select::make('patient_id')
->label('Patient')
->relationship('patient', 'full_name')
->searchable(['full_name', 'id_number', 'pat_num'])
->createOptionForm(PatientResource::modal_form()) // Complete form for the modal
->createOptionModalHeading('Create Patient')
->suffixAction(
Action::make('copy_to_guarantor')
->icon('heroicon-m-clipboard')
->action(function (Set $set, $state) {
$set('guarantor_id', $state);
})
)
->required()
->live(),
Select::make('patient_id')
->label('Patient')
->relationship('patient', 'full_name')
->searchable(['full_name', 'id_number', 'pat_num'])
->createOptionForm(PatientResource::modal_form()) // Complete form for the modal
->createOptionModalHeading('Create Patient')
->suffixAction(
Action::make('copy_to_guarantor')
->icon('heroicon-m-clipboard')
->action(function (Set $set, $state) {
$set('guarantor_id', $state);
})
)
->required()
->live(),
In addition, once the patient is selected, it must be displayed so that it can be updated in case any information has changed. I have made the Select live() in the hopes that the chosen or created patient's data can be presented in thuis section for editing:
Section::make()
->relationship('patient')
->schema(
PatientResource::schema() // Array of patient fields
)
->columns(2),
Section::make()
->relationship('patient')
->schema(
PatientResource::schema() // Array of patient fields
)
->columns(2),
I am obviously not doing the thing properly, because the fields in the section do not respond to changes in the select at all. What do I need to do?
3 replies
FFilament
Created by WiseWill on 8/5/2023 in #❓┊help
Modal form for url action on panel
Is there any way I could open a modal before opening a url from an action? I want to open a custom form, and then use data from the form as a parameter on the url. This doesn't work at all, the url is simply opened. I would like to replace "cash" in the url with the value selected in the form.
Action::make('tarriff_schedules')
->label('Tarriff Schedules')
->icon('heroicon-s-clipboard-list')
->form([
Select::make('Schedule')
->options(function () {
$options = ['Cash' => 'cash'];
$schedules = config('labman.tarriff_schedules');
foreach ($schedules as $schedule) {
$options[$schedule] = $schedule;
}
return $options;
})
])
->url(function () {
return route('tarriff-schedules', 'cash');
},true)
Action::make('tarriff_schedules')
->label('Tarriff Schedules')
->icon('heroicon-s-clipboard-list')
->form([
Select::make('Schedule')
->options(function () {
$options = ['Cash' => 'cash'];
$schedules = config('labman.tarriff_schedules');
foreach ($schedules as $schedule) {
$options[$schedule] = $schedule;
}
return $options;
})
])
->url(function () {
return route('tarriff-schedules', 'cash');
},true)
3 replies