Arnaud
Arnaud
Explore posts from servers
FFilament
Created by Arnaud on 1/31/2024 in #❓┊help
Repeater show field based on line number
Hello, I would like to display a field in my repeater only if the current repeated element is not the first. I've done this code that works well but I'm sure there is a better way to do it :
->visible(function (Component $component, Get $get) {
if ($get('../../conditions') === null) {
return false;
}

$statePath = $component->getContainer()->getStatePath();
$statePath = explode('.', $statePath);
$statePath = end($statePath);

if (array_key_first($get('../../conditions')) === $statePath) {
return false;
}

return true;
})
->visible(function (Component $component, Get $get) {
if ($get('../../conditions') === null) {
return false;
}

$statePath = $component->getContainer()->getStatePath();
$statePath = explode('.', $statePath);
$statePath = end($statePath);

if (array_key_first($get('../../conditions')) === $statePath) {
return false;
}

return true;
})
Best regards
2 replies
FFilament
Created by Arnaud on 1/19/2024 in #❓┊help
Add dynamic columns in table
Hello, Not help but maybe somebody can find it when searching. I was looking to add some columns to my table. I have a resource who has many states. The states can be created dynamically from the database and in my case the relation is MorphToMany 😅 But easy to add it to Filament : 1/ Add the getTableColumns() function 2/ Inside, push new columns to exist ones
$columns = [
// others columns I've already created
];

foreach ($this->stages as $stage) {
$columns[] = TextColumn::make('stages.['.$stage->id.'].name')
->label($stage->name)
->placeholder('-')
->toggleable(isToggledHiddenByDefault: true)
->state(function ($record) use ($stage) {
$selectedStage = $record->stages->where('id', $stage->id)->first();

if (! $selectedStage) { return; }
return $selectedStage->pivot->created_at->format('d/m/Y');
});
}

return $columns;
$columns = [
// others columns I've already created
];

foreach ($this->stages as $stage) {
$columns[] = TextColumn::make('stages.['.$stage->id.'].name')
->label($stage->name)
->placeholder('-')
->toggleable(isToggledHiddenByDefault: true)
->state(function ($record) use ($stage) {
$selectedStage = $record->stages->where('id', $stage->id)->first();

if (! $selectedStage) { return; }
return $selectedStage->pivot->created_at->format('d/m/Y');
});
}

return $columns;
Enjoy
2 replies
FFilament
Created by Arnaud on 1/19/2024 in #❓┊help
Sidebar toggle fail
No description
7 replies
FFilament
Created by Arnaud on 12/31/2023 in #❓┊help
Strange behavior with sort in views
Hello, I have for exemple a public variable $events, filled by a simple eloquent call : $this->record->events()->orderBy('events.start_at', 'desc')->get(); On controller part, the order is good, if I die and dump on view, it's good but it seems, with the page hydration, I see a glitch and my results are not in the same order. How can I manage that ? Best regards,
8 replies
FFilament
Created by Arnaud on 12/22/2023 in #❓┊help
Use Notification for error 500 in production
Hello, With error handling, how do you manage to display a notification instead of the classical big gray screen for error 500 in production ? I just would like to say there is an error, contact the support. Best regards,
6 replies
FFilament
Created by Arnaud on 12/19/2023 in #❓┊help
Enormous class size
Hello, Just wondering if is it me but I'm often reach 1k+ rows of code in my class (resource or page). How to you manage / split your code to keep something clean and readable ? Best regards,
5 replies
FFilament
Created by Arnaud on 11/29/2023 in #❓┊help
Hide form loose state
I have a livewire component who own many sub components. If I do something like that :
@if($step === 2)
<div>
<livewire:sub-component />
</div>
@endif
@if($step === 2)
<div>
<livewire:sub-component />
</div>
@endif
Every time I change step, I will get many error messages in console :
Uncaught ReferenceError: state is not defined
Uncaught ReferenceError: state is not defined
Any idea how to completely hide from page a form and reshow it without problem ?
5 replies
FFilament
Created by Arnaud on 11/5/2023 in #❓┊help
Tenant admin color
Hello, Do you know a way to get Tenant in Filament Provider in order to have the current Tenant ? The idea behind that is to set a color per Panel I've tried to use the bootUsing method in $panel, but set $panel->colors no update the color ... The problem with AppServiceProvider is I can't get current tenant or even route ...
7 replies
FFilament
Created by Arnaud on 11/2/2023 in #❓┊help
Filter by pivot
Hello, I'm looking for a way to filter a table by pivot column. I'm using it inside a full Filament v3 admin panel. For exemple, I have Users and Teams. They are linked by a pivot table with three columns : - user_id - team_id - role When I would like to update the baseQuery :
$query->whereHas('teams', function ($query) use ($role) {
$query->where('team_user.role', $role);
});
$query->whereHas('teams', function ($query) use ($role) {
$query->where('team_user.role', $role);
});
I got an error message :
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'where clause'
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'where clause'
Because in my select filters make method I have put 'role'. I've tried so far : - make('team.role') - make('teams.pivot.role') ... In my models, I have correctly set-up withPivot('role') How to filter by pivot column ?
2 replies