Action does not open a custom modal
Hi everyone!
I have a custom query defined on my List Page to group and sum inventory quantity based on locations:
I need a button on each row to display the grouped value detail records. The following code does not open a modal:
Simple blade code to test it:
Thanks in advance!
I have a custom query defined on my List Page to group and sum inventory quantity based on locations:
namespace App\Filament\Resources\InventoryResource\Pages;
protected function getTableQuery(): Builder
{
// Return all inventories records but group by asset_id and sum the quantity
return Inventory::selectRaw('
random() as id,
asset_id,
location_id,
sum(quantity) as quantity
')
->addSelect('assets.name as asset_name')
->addSelect('locations.name as location_name')
->groupBy('asset_id', 'location_id', 'asset_name', 'location_name')
->leftJoin('assets', 'assets.id', '=', 'inventories.asset_id')
->leftJoin('locations', 'locations.id', '=', 'inventories.location_id');
//
}namespace App\Filament\Resources\InventoryResource\Pages;
protected function getTableQuery(): Builder
{
// Return all inventories records but group by asset_id and sum the quantity
return Inventory::selectRaw('
random() as id,
asset_id,
location_id,
sum(quantity) as quantity
')
->addSelect('assets.name as asset_name')
->addSelect('locations.name as location_name')
->groupBy('asset_id', 'location_id', 'asset_name', 'location_name')
->leftJoin('assets', 'assets.id', '=', 'inventories.asset_id')
->leftJoin('locations', 'locations.id', '=', 'inventories.location_id');
//
}I need a button on each row to display the grouped value detail records. The following code does not open a modal:
namespace App\Filament\Resources;
public static function table(Table $table): Table {
return $table
->columns([
...
])
->actions([
// Show Inventory records
Action::make('show_records')
->label(__('Show Records'))
->action(fn ($record) => $record->advance())
->modalContent(fn ($record) => view('filament.pages.actions.inventory-show-records', ['record' => $record]))
//
])
}namespace App\Filament\Resources;
public static function table(Table $table): Table {
return $table
->columns([
...
])
->actions([
// Show Inventory records
Action::make('show_records')
->label(__('Show Records'))
->action(fn ($record) => $record->advance())
->modalContent(fn ($record) => view('filament.pages.actions.inventory-show-records', ['record' => $record]))
//
])
}Simple blade code to test it:
<x-filament::modal>
<x-slot name="header">
Show Records
</x-slot>
<div>
{{ $this->id }}
</div>
</x-filament::modal><x-filament::modal>
<x-slot name="header">
Show Records
</x-slot>
<div>
{{ $this->id }}
</div>
</x-filament::modal>Thanks in advance!
Solution
I just resolved it. The issue was the random value used as ID
return Inventory::selectRaw('
random() as id,return Inventory::selectRaw('
random() as id,