WiseWill
WiseWill
FFilament
Created by WiseWill on 3/14/2024 in #❓┊help
Caching Filament components
Thank you, and Happy Birthday! Problem indeed solved, and way faster now.
11 replies
FFilament
Created by WiseWill on 1/22/2024 in #❓┊help
Unauthenticated exception thrown instead of a login page
I don't know if this is very elegant, but it is how I resolved my issue:
<?php

namespace App\Http\Middleware;

use Filament\Http\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
/**
* Handle an unauthenticated user.
*
* @param \Illuminate\Http\Request $request
* @param array $guards
* @return void
*
* @throws \Illuminate\Auth\AuthenticationException
*/
protected function unauthenticated($request, array $guards)
{
if ($request->expectsJson()) {
// Don't offer API requests a login page.
exit(response()->json(['message' => 'Unauthenticated.'], 401));
}

$url = $this->redirectTo($request);
exit("<script>window.location.href = '{$url}';</script>");
}
}
<?php

namespace App\Http\Middleware;

use Filament\Http\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
/**
* Handle an unauthenticated user.
*
* @param \Illuminate\Http\Request $request
* @param array $guards
* @return void
*
* @throws \Illuminate\Auth\AuthenticationException
*/
protected function unauthenticated($request, array $guards)
{
if ($request->expectsJson()) {
// Don't offer API requests a login page.
exit(response()->json(['message' => 'Unauthenticated.'], 401));
}

$url = $this->redirectTo($request);
exit("<script>window.location.href = '{$url}';</script>");
}
}
and
<?php

namespace App\Providers\Filament;

use App\Http\Middleware\Authenticate;
// other classes

class AppPanelProvider extends PanelProvider
{ // normal stuff }
<?php

namespace App\Providers\Filament;

use App\Http\Middleware\Authenticate;
// other classes

class AppPanelProvider extends PanelProvider
{ // normal stuff }
4 replies
FFilament
Created by Stefan on 1/2/2024 in #❓┊help
Add a filament Table into a form Section
Not knowing your database schema I am taking a shot in the dark. It may make sense to store the product properties in a JSON column on the products table, and then use a repeater field to achieve what you want. I have used the TableRepeater "field" (https://filamentphp.com/plugins/awcodes-table-repeater) to solve a similar need. I made some notes here: https://nettsite.co.za/simplifying-laravel-eloquent-and-filament-storing-contacts-with-ease/
4 replies
FFilament
Created by axellounge on 1/3/2024 in #❓┊help
Flash of Unstyled Content
I have had a careful look, but I don't see it at all - looks fine from the get go. I don't have a particularly fast connection, 6 Mbps right now, and not a great big PC - I3 processor, 16MB RAM, running Ubuntu 22.04 and Chrome.
3 replies
FFilament
Created by WiseWill on 1/1/2024 in #❓┊help
notification color
I found it - create a custom theme, and then in theme.css add
.fi-no-notification {
background-color : rgba(var(--primary-600),var(--tw-bg-opacity));
}

.fi-no-notification-title {
color: whitesmoke !important;
font-size: 1.25rem !important;
line-height: 1.5rem !important;
}

.fi-no-notification-body {
color: whitesmoke !important;
}
.fi-no-notification {
background-color : rgba(var(--primary-600),var(--tw-bg-opacity));
}

.fi-no-notification-title {
color: whitesmoke !important;
font-size: 1.25rem !important;
line-height: 1.5rem !important;
}

.fi-no-notification-body {
color: whitesmoke !important;
}
Hopefully the CSS classes don't change in future versions.
4 replies
FFilament
Created by IranMine123 on 12/22/2023 in #❓┊help
Bulk Deleting on not migrated Tables
👍
13 replies
FFilament
Created by IranMine123 on 12/22/2023 in #❓┊help
Bulk Deleting on not migrated Tables
Of course, the delete statement will be "delete from table where primary_key = 'value'". If every row has the same value.......
13 replies
FFilament
Created by IranMine123 on 12/22/2023 in #❓┊help
Bulk Deleting on not migrated Tables
That normally works for me. I assume the column you are using contains unique entries, even if it isn't the primary key? A unique key at least?
13 replies
FFilament
Created by IranMine123 on 12/22/2023 in #❓┊help
Bulk Deleting on not migrated Tables
Did you define the primary key? That is the important bit. That is how you change it to other Column.
13 replies
FFilament
Created by IranMine123 on 12/22/2023 in #❓┊help
Bulk Deleting on not migrated Tables
I assume the table has a primary key column with some name other than "id". If that is the case, all you might need to do is specify the primary key on the model:
protected $primaryKey = 'pk'; // or whatever it is called
public $timestamps = false; // Probably doesn't have timestamps
protected $primaryKey = 'pk'; // or whatever it is called
public $timestamps = false; // Probably doesn't have timestamps
13 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.
Got it!
Select::make('patient_id')
->label('Patient')
->relationship('patient', 'full_name')
->searchable(['full_name', 'id_number', 'pat_num'])
->native(false)
->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()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('patient-details')
->getChildComponentContainer()
->fill(Patient::find($component->getState('patient_id'))->toArray())
),
Select::make('patient_id')
->label('Patient')
->relationship('patient', 'full_name')
->searchable(['full_name', 'id_number', 'pat_num'])
->native(false)
->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()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('patient-details')
->getChildComponentContainer()
->fill(Patient::find($component->getState('patient_id'))->toArray())
),
3 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.
I have made a little progress. I have added a key to my Section:
Section::make()
->key('patient-details')
->relationship('patient')
->schema(
PatientResource::schema() // Array of patient fields
)
->columns(2),
Section::make()
->key('patient-details')
->relationship('patient')
->schema(
PatientResource::schema() // Array of patient fields
)
->columns(2),
and I have added a callback (taken from the docs) to the Select:
Select::make('patient_id')
->label('Patient')
->relationship('patient', 'full_name')
->searchable(['full_name', 'id_number', 'pat_num'])
->native(false)
->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()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('patient-details')
->getChildComponentContainer()
->fill()
),
Select::make('patient_id')
->label('Patient')
->relationship('patient', 'full_name')
->searchable(['full_name', 'id_number', 'pat_num'])
->native(false)
->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()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('patient-details')
->getChildComponentContainer()
->fill()
),
Now the patient details in the Section are emptied if I change the patient while editing the requisition. How do I get the actual Patient model to fill those fields with?
3 replies
FFilament
Created by WiseWill on 8/5/2023 in #❓┊help
Modal form for url action on panel
Thanks, I will give it a try.
3 replies