acroninja
acroninja
FFilament
Created by acroninja on 6/22/2024 in #❓┊help
Select Filter with nested relation won't filter
public static function productFilter($relationship = 'lineItem.product'){
return SelectFilter::make($relationship)
->label('Product')
->relationship($relationship, 'name')
->native(false)
->preload()
->searchable();
}
public static function productFilter($relationship = 'lineItem.product'){
return SelectFilter::make($relationship)
->label('Product')
->relationship($relationship, 'name')
->native(false)
->preload()
->searchable();
}
If we use a direct relationship the select filter works Nested relations provide the correct dropdown options but does not filter the results If try to add a query or ->modifyQueryUsing $data array is never populated.
->query(function (Builder $query, array $data) use ($relationship) {
if (isset($data['value'])) {
$query->whereHas($relationship, function ($query) use ($data) {
$query->where('id', $data['value']);
});

}
})
->query(function (Builder $query, array $data) use ($relationship) {
if (isset($data['value'])) {
$query->whereHas($relationship, function ($query) use ($data) {
$query->where('id', $data['value']);
});

}
})
Also tried to create direct relation on the model like this but throws an error
public function productCategory(): BelongsTo
{
return $this->product()->productCategory();
}
public function productCategory(): BelongsTo
{
return $this->product()->productCategory();
}
5 replies
FFilament
Created by acroninja on 6/7/2024 in #❓┊help
Duplicate navigation items when overriding a package resource.
In my package i've made shouldRegisterNavigation a config option like this
class ConsentOptionResource extends Resource
{
protected static ?string $model = ConsentOption::class;

public static function shouldRegisterNavigation(): bool
{
return config('filament-user-consent.navigation.consent_options.register');
}
class ConsentOptionResource extends Resource
{
protected static ?string $model = ConsentOption::class;

public static function shouldRegisterNavigation(): bool
{
return config('filament-user-consent.navigation.consent_options.register');
}
Which hides menu item when set to false. We've then created a local override for this file due to client customisation requirements and set shoudRegisterNavigation to true
use Visualbuilder\FilamentUserConsent\Resources\ConsentOptionResource as BaseConsentOptionResource;

class ConsentOptionResource extends BaseConsentOptionResource
{
protected static ?string $model = ConsentOption::class;

public static function shouldRegisterNavigation(): bool
{
return true;
}
use Visualbuilder\FilamentUserConsent\Resources\ConsentOptionResource as BaseConsentOptionResource;

class ConsentOptionResource extends BaseConsentOptionResource
{
protected static ?string $model = ConsentOption::class;

public static function shouldRegisterNavigation(): bool
{
return true;
}
But for some reason this duplicates the menu item in the cluster. I've tried setting shouldRegisterNavigation to false and manually registering the nav item in the panel config but it looks like clusters aren't yet supported in
Filament\Navigation\NavigationItem
Filament\Navigation\NavigationItem
so I it won't show in the correct menu. Anyone else had this issue or can suggest a solution? Thanks
4 replies
FFilament
Created by acroninja on 5/11/2024 in #❓┊help
Checkbox list from relation only orders by title? Solved just use modifyQueryUsing
We need to order a checkbox list by ID so that the option "Other" always comes last as it is when ordered by id. I'm going to create an override of the CheckboxList class relationship function but wondering if others have this issue and maybe it would be nice to have an orderBy option for the list
4 replies
FFilament
Created by acroninja on 4/29/2024 in #❓┊help
Is it possible to defer loading of panel service providers?
I have different panels on different domains, there's no point loading other panels.
2 replies
FFilament
Created by acroninja on 4/16/2024 in #❓┊help
How to change the session cookie name between panels?
We have an app with 3 different admin panels each with their own auth guard. This is causing a problem if you login to 2 different panels on the same browser. It's fine if you clear cookies or go incognito.
I just need the session cookie to be named differently between the panels - can anyone suggest a method to achieve this?
5 replies
FFilament
Created by acroninja on 4/13/2024 in #❓┊help
Unable to download export with polymorphic user and custom guard
Our export migration uses the $table->morphs('user'); and in a service provider i have Export::polymorphicUserRelationship(); But accessing the download url redirects me to /admin/login even though I am already logged in. The download route uses the 'filament.actions' middleware group:-
Route::get('/filament/exports/{export}/download', DownloadExport::class)
->name('filament.exports.download')
->middleware('filament.actions');
Route::get('/filament/exports/{export}/download', DownloadExport::class)
->name('filament.exports.download')
->middleware('filament.actions');
Which is created in ActionsServiceProvider:-
public function packageRegistered(): void
{
app(Router::class)->middlewareGroup('filament.actions', ['web', 'auth']);
}
public function packageRegistered(): void
{
app(Router::class)->middlewareGroup('filament.actions', ['web', 'auth']);
}
(not used by anything else) but I need the 'auth:admin middleware. I did add $this->app->bind(Authenticatable::class, Admin::class); also to the service provider but doesn't help, without the correct auth guard we're not going to get that far. Should i just override the ActionsServiceProvider or is there a better filament way? Thx for any tips
3 replies
FFilament
Created by acroninja on 4/6/2024 in #❓┊help
Bug with sidebar notifications not marked as read but deleted
When you dismiss a sidebar notification they are deleted rather than marked as read. Not sure this should be the expected behaviour. Haven't dug into the code yet, does anyone know if this is an easy fix? Notification log is a useful audit history feature
2 replies
FFilament
Created by acroninja on 3/12/2024 in #❓┊help
Is it possible to load a table inside an Action Form?
I need to provide more information to the user than is practical in a Select. Is it possible to replace the select with a table and allow the user to click a row to select the option?
4 replies
FFilament
Created by acroninja on 2/27/2024 in #❓┊help
Where to put @livewire('database-notifications')
The docs say put this in your blade layout. https://filamentphp.com/docs/3.x/notifications/database-notifications Do I need to create an override for views/components/layout/simple.blade.php and add it here or is there a better way to do it?
14 replies
FFilament
Created by acroninja on 8/30/2023 in #❓┊help
Repeater relations meta data not merged with existing and overwrites other meta data.
I have 2 forms, each have different fields that both save in the SAME meta json column on the relation. form1: meta.passport.number + meta.passport.expiry form2: meta.nationality + meta.date_of_birth. The data from each form is saved but does not merge with existing meta. I've tried using the handleRecordUpdate and mutateFormDataBeforeSave on the page but $data is empty.
Have tried getting existing data from $this->record and merging with $this->data but the relationship save happens before these functions are called. In src/Components/Repeater.php the $this->saveRelationshipsUsing( has the correct data all merged in $state but then it's lost a bit further down. Is this expected behavior? Perhaps a workaround solution is to create a separate json column for each form - but I have 12 forms each with some different meta. Feels a bit clunky to make separate columns. Any advice gratefully received. Ta.
4 replies
FFilament
Created by acroninja on 8/28/2023 in #❓┊help
Form wizard loses values from previous steps after page reload
Maybe this is the correct action after page refresh, but with the step url parameter I end up halfway through the wizard but without previous steps having any values. Should I check for this and redirect back to step 1?
3 replies
FFilament
Created by acroninja on 8/26/2023 in #❓┊help
Is it possible to have a panel that is public without authentication?
Currently if I remove auth middleware the Filament\FilamentManager::getUserAvatarUrl() can't find an auth user so throws an error. Don't know if it's worth trying to make this work or not?
14 replies
FFilament
Created by acroninja on 8/25/2023 in #❓┊help
How to add a repeating infolist to show all records from a resource?
I can see how to define an infolist but would like to give it a datasource of Model::all() to show all records as cards. I'd like to add this to a custom page or if it's easier I can create a new resource.
Effectively I need a list page but in a grid format instead of a table. Any suggestions gratefully received, can't tell from the docs if I need to create a custom livewire component or if I can add it to a resource page?
4 replies
FFilament
Created by acroninja on 7/8/2023 in #❓┊help
Select On Change
I have a Select on a custom admin page form and would like to update the form fields -> or even trigger a url action when selecting from the dropdown. ie load a new record into the form. Select::make('id')->options($emailTemplates)
13 replies