Vincent Klaiber
Vincent Klaiber
FFilament
Created by Vincent Klaiber on 2/19/2024 in #❓┊help
What is the optimal path for custom authentication in Filament?
1. Develop a custom Password Broker in Laravel. 2. Extend and override default login, request password reset, and reset password components in Filament. 3. Create new custom Livewire pages.
1 replies
FFilament
Created by Vincent Klaiber on 11/29/2023 in #❓┊help
Counting relationships performance
Can we improve the performance of many-to-many text column counting relationships?
Tables\Columns\TextColumn::make('users_count')->counts('users');
Tables\Columns\TextColumn::make('users_count')->counts('users');
This code executes the SQL query below, which takes approximately 22 seconds to complete:
SELECT `notifications`.*,
(
SELECT count(*)
FROM `users`
inner join `notification_user` on `users`.`id` = `notification_user`.`user_id`
WHERE `notifications`.`id` = `notification_user`.`notification_id`
) as `users_count`
FROM `notifications`
ORDER BY `created_at` DESC
LIMIT 10 offset 0;
SELECT `notifications`.*,
(
SELECT count(*)
FROM `users`
inner join `notification_user` on `users`.`id` = `notification_user`.`user_id`
WHERE `notifications`.`id` = `notification_user`.`notification_id`
) as `users_count`
FROM `notifications`
ORDER BY `created_at` DESC
LIMIT 10 offset 0;
Can Filament enhance the query's performance? The custom query below currently takes approximately 3 seconds to execute on a table with over 1 million rows.
SELECT
`notifications`.*,
COUNT(DISTINCT `notification_user`.`user_id`) AS `users_count`
FROM `notifications`
LEFT JOIN `notification_user` ON `notification_user`.`notification_id` = `notifications`.`id`
GROUP BY `notifications`.`id`
ORDER BY `notifications`.`created_at` DESC
LIMIT 10
OFFSET 0;
SELECT
`notifications`.*,
COUNT(DISTINCT `notification_user`.`user_id`) AS `users_count`
FROM `notifications`
LEFT JOIN `notification_user` ON `notification_user`.`notification_id` = `notifications`.`id`
GROUP BY `notifications`.`id`
ORDER BY `notifications`.`created_at` DESC
LIMIT 10
OFFSET 0;
2 replies
FFilament
Created by Vincent Klaiber on 6/26/2023 in #❓┊help
Improve search performance
How can I optimize search performance for multiple columns in Filament when dealing with a table containing over 700,000 records?
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->searchable(),
Tables\Columns\TextColumn::make('name')->searchable([
'first_name',
'last_name',
]),
Tables\Columns\TextColumn::make('email')->searchable(),
]);
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->searchable(),
Tables\Columns\TextColumn::make('name')->searchable([
'first_name',
'last_name',
]),
Tables\Columns\TextColumn::make('email')->searchable(),
]);
30 replies
FFilament
Created by Vincent Klaiber on 3/3/2023 in #❓┊help
Conditional form relationships
Is there a way to fetch related models, in the same form, based on another field value?
Select::make('user_id')
->label('User')
->options(User::all()->pluck('name', 'id'))
->required(),
Select::make('post_id')
->label('Post')
->options(Post::where('author_id', 'SELECTED-USER-ID?')->get()->pluck('name', 'id'))
->required(),
Select::make('user_id')
->label('User')
->options(User::all()->pluck('name', 'id'))
->required(),
Select::make('post_id')
->label('Post')
->options(Post::where('author_id', 'SELECTED-USER-ID?')->get()->pluck('name', 'id'))
->required(),
1. Is there a way to list posts by the selected user? SELECTED-USER-ID 2. Is there a way to disable the post select field until a user is selected?
6 replies