Jonas
Jonas
FFilament
Created by Jonas on 10/9/2024 in #❓┊help
Duplicate navigationbadge query with multitenancy
Hey, I'm using getNavigationFeature() in a FilamentPHP multitenancy app, like this:
public static function getNavigationBadge(): ?string
{
$waitingTasksCount = CustomerTask::waitingOnCustomer()->count();
return $waitingTasksCount > 0 ? (string) $waitingTasksCount : null;
}
public static function getNavigationBadge(): ?string
{
$waitingTasksCount = CustomerTask::waitingOnCustomer()->count();
return $waitingTasksCount > 0 ? (string) $waitingTasksCount : null;
}
While investigating with Laravel Debugbar, I noticed that the query runs for every tenant the user has access to, which seems unnecessary. For example, if I, as a user, have access to 10 customers, each page load runs 10 queries to get the navigation badge for each customer—even though only the active tenant is displayed and needed. I also noticed that it queries navigation badges for another panel on each page load, leading to even more unnecessary queries. Is there a way to ensure it only runs the query for the selected tenant and only within the same panel or is it a config issue on my end?
5 replies
FFilament
Created by Jonas on 4/29/2024 in #❓┊help
Defining record in Table EditAction not working
Hi I am having an issue with the table EditAction when using another model than what the table record has. My setup has a task model and then a taskAnswer model (witch belongs to the task). My issue is that even though i define EditRecord to edit the taskanswer, it tries to update the task instead. (I have removed alot of irrelevant code in below snippets) Edit Action
public static function editAnswerAction()
{
return Tables\Actions\EditAction::make()
->model(TaskAnswer::class)
->record(function (Task $record): TaskAnswer {
return $record->answer;
})
->mutateFormDataUsing(function (array $data, Task $ownerRecord): array {
$data["user_id"] = auth()->id();
return static::resolveDataManipulation($ownerRecord, $data);
})
->steps(function(Task $record) {
return static::resolveModalSteps($record);
});
}
public static function editAnswerAction()
{
return Tables\Actions\EditAction::make()
->model(TaskAnswer::class)
->record(function (Task $record): TaskAnswer {
return $record->answer;
})
->mutateFormDataUsing(function (array $data, Task $ownerRecord): array {
$data["user_id"] = auth()->id();
return static::resolveDataManipulation($ownerRecord, $data);
})
->steps(function(Task $record) {
return static::resolveModalSteps($record);
});
}
This tries to update the task, and not the task answer - even though i have defined both model and record. Im kinda stuck here.. I have a similiar approach to create record, and that works fine.
public static function createAnswerAction()
{
return Tables\Actions\CreateAction::make()
->model(TaskAnswer::class)
->mutateFormDataUsing(function (array $data, Task $ownerRecord): array {
$data["task_id"] = $ownerRecord->id;
$data["user_id"] = auth()->id();
return static::resolveDataManipulation($ownerRecord, $data);
})
->steps(function(Task $record) {
return static::resolveModalSteps($record);
});
}
public static function createAnswerAction()
{
return Tables\Actions\CreateAction::make()
->model(TaskAnswer::class)
->mutateFormDataUsing(function (array $data, Task $ownerRecord): array {
$data["task_id"] = $ownerRecord->id;
$data["user_id"] = auth()->id();
return static::resolveDataManipulation($ownerRecord, $data);
})
->steps(function(Task $record) {
return static::resolveModalSteps($record);
});
}
2 replies
FFilament
Created by Jonas on 2/17/2024 in #❓┊help
Using table builder with an external API
Hi. I have been following the guide here: https://filamentphp.com/community/how-to-consume-an-external-api-with-filament-tables This works good an all, however here is my problem: - I need to define query paramaters on the actual API, not the model (so in order to first populate the model, i need to define variables when polling the API). How would i approach something like this?
3 replies
FFilament
Created by Jonas on 2/14/2024 in #❓┊help
Removing title from relationmanager and remove "View" from ViewRecord
No description
2 replies