Lietze
Lietze
FFilament
Created by Lietze on 6/7/2024 in #❓┊help
Changes update toggleable columns
No description
6 replies
FFilament
Created by Lietze on 4/3/2024 in #❓┊help
Fill Select on relationmanager creation form
How can i pre-fill parent relation selector on a create form on a relationmananger? On the Practice View, i have a Patient relationmanager, and when i create a new patient on that page, i want to have already selected the practice, but i'm not sure how I can implement that.
Select::make('practice_id')
->label('Practice')
->helperText(fn (string $operation) => $operation !== 'view' ? 'If the practice you are looking for is not in the list, please make sure it has a filled name.' : '')
->placeholder('Select a practice')
->options(fn () => Practice::all()
->pluck('filled_name', 'id')
->sort(SORT_NATURAL | SORT_FLAG_CASE)
->toArray()
),
Select::make('practice_id')
->label('Practice')
->helperText(fn (string $operation) => $operation !== 'view' ? 'If the practice you are looking for is not in the list, please make sure it has a filled name.' : '')
->placeholder('Select a practice')
->options(fn () => Practice::all()
->pluck('filled_name', 'id')
->sort(SORT_NATURAL | SORT_FLAG_CASE)
->toArray()
),
I tried using afterStateHydrated, but I'm not sure which injections i need to get to get the ID of the practice of which page I'm on right now.
3 replies
FFilament
Created by Lietze on 12/21/2023 in #❓┊help
Column 'name' in where clause is ambiguous
I have quite an extensive admin-panel with lots of columns and custom filters/queries. This works fine for most options, but when I try to search for things (and sometimes with sorting but that's an issue for later), I get the error as mentioned in the title. This is most likely caused by the fact that I have two tables with the column 'name': Patients and Practices, which makes SQL unsure about in what table to look for. Part of the Laravel SQL error:
...
AND (
EXISTS (
SELECT
*
FROM
`patients`
WHERE
`examinations`.`patient_id` = `patients`.`id`
AND `name` LIKE % sudw %
AND `patients`.`deleted_at` IS NULL
)
OR EXISTS (
SELECT
*
FROM
`practices`
INNER JOIN `patients` ON `patients`.`practice_id` = `practices`.`id`
WHERE
`patients`.`id` = `examinations`.`patient_id`
AND `name` LIKE % sudw %
AND `practices`.`deleted_at` IS NULL
AND `patients`.`deleted_at` IS NULL
)
...
...
AND (
EXISTS (
SELECT
*
FROM
`patients`
WHERE
`examinations`.`patient_id` = `patients`.`id`
AND `name` LIKE % sudw %
AND `patients`.`deleted_at` IS NULL
)
OR EXISTS (
SELECT
*
FROM
`practices`
INNER JOIN `patients` ON `patients`.`practice_id` = `practices`.`id`
WHERE
`patients`.`id` = `examinations`.`patient_id`
AND `name` LIKE % sudw %
AND `practices`.`deleted_at` IS NULL
AND `patients`.`deleted_at` IS NULL
)
...
My columns are defined as followed:
public static function patient(): TextColumn
{
return self::createColumn('patient.name', 'Patient')
->searchable()
->sortable();
}

public static function practice(): TextColumn
{
return self::createColumn('practice.name')
->searchable()
->sortable()
->limit(25);
}

protected static function createColumn(string $name, ?string $label = null, bool $defaultHidden = false): TextColumn
{
return TextColumn::make($name)
->label($label)
->toggleable(Admin::isGlobalAdmin(), $defaultHidden)
->alignCenter();
}
public static function patient(): TextColumn
{
return self::createColumn('patient.name', 'Patient')
->searchable()
->sortable();
}

public static function practice(): TextColumn
{
return self::createColumn('practice.name')
->searchable()
->sortable()
->limit(25);
}

protected static function createColumn(string $name, ?string $label = null, bool $defaultHidden = false): TextColumn
{
return TextColumn::make($name)
->label($label)
->toggleable(Admin::isGlobalAdmin(), $defaultHidden)
->alignCenter();
}
What could be a good way to solve this problem? Thanks in advance!
2 replies
FFilament
Created by Lietze on 12/21/2023 in #❓┊help
How to find the current query of the list page?
I have this page where i get 2236 results by default, but when i tinker with Model::count() i get 150 more results than my resource list.. to debug this i would like to see the query built to show the results, so i can figure out what i did wrong
5 replies
FFilament
Created by Lietze on 12/18/2023 in #❓┊help
filter form - reset filter A when filter B is some value
I'm trying to reset a filter when another filter is set to a specific value. so when has_lab_report is set back to false or show all, the results filter should be invisible again (which happens), but the filter is still active with the previously selected options (positive/negative etc) How can i reset the results filter when has_lab_reports is not Yes?
class LabReportResultFilter extends Filter
{
protected function setUp(): void
{
parent::setUp();

$this->label('Has result');
$this->form([
Grid::make()->schema([
Select::make('has_lab_report')
->placeholder('Show all')
->options([
'true' => 'Yes',
'false' => 'No',
])
// ->afterStateHydrated(function ($state, Set $set, Get $get) {
// if ($state) {
// $set('results', []);
// }
// })
,
// TODO reset 'results' when 'has_lab_report' is not 'true' anymore

Select::make('results')
->placeholder('Select a result')
->visible(fn (Get $get) => $get('has_lab_report') == 'true')
->multiple()
->options([
'positive' => 'Positive',
'negative' => 'Negative',
'dubious' => 'Dubious',
]),
]),
]);
// $this->query etc etc
class LabReportResultFilter extends Filter
{
protected function setUp(): void
{
parent::setUp();

$this->label('Has result');
$this->form([
Grid::make()->schema([
Select::make('has_lab_report')
->placeholder('Show all')
->options([
'true' => 'Yes',
'false' => 'No',
])
// ->afterStateHydrated(function ($state, Set $set, Get $get) {
// if ($state) {
// $set('results', []);
// }
// })
,
// TODO reset 'results' when 'has_lab_report' is not 'true' anymore

Select::make('results')
->placeholder('Select a result')
->visible(fn (Get $get) => $get('has_lab_report') == 'true')
->multiple()
->options([
'positive' => 'Positive',
'negative' => 'Negative',
'dubious' => 'Dubious',
]),
]),
]);
// $this->query etc etc
3 replies
FFilament
Created by Lietze on 11/7/2023 in #❓┊help
Copy to clipboard action table
No description
18 replies
FFilament
Created by Lietze on 11/6/2023 in #❓┊help
Relationmanager for other items from same user
I have a payment and user model. On the payment page i would like to show all the other payments from that same user, is this possible? And if so, what would be the simplest way to achieve this? so basically a relationmanager for payment.user.payments
10 replies