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');
//
}