Multiple Resources with different table query but tables appearance is not different
In my list I overridden getTableQuery() based on path
<?php
namespace App\Filament\Resources\BiciklResource\Pages;
use App\Filament\Resources\BiciklResource;
use App\Filament\Resources\BiciklAktivniResource;
use App\Filament\Resources\BiciklArhivaResource;
use App\Models\Bicikl;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
class ListBicikls extends ListRecords
{
protected static string $resource = BiciklResource::class;
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
];
}
protected function getTableRecordsPerPageSelectOptions(): array
{
return [12, 24, 48, 96, -1];
}
protected function getTableQuery(): Builder
{
$path = request()->getPathInfo();
if ($path === '/admin/bicikli-aktivni') {
return parent::getTableQuery()->where('pCena', null);
} else if ( $path === '/admin/bicikli-arhiva' ) {
return parent::getTableQuery()->whereNotNull('pCena');
} else {
return parent::getTableQuery()->withoutGlobalScopes();
}
}
}
But, even I changed tables in my Resources, they all look like one in BiciklResource. That's probably becuase of this line protected static string $resource = BiciklResource::class;
Can I set this conditionally too or there is another way?
<?php
namespace App\Filament\Resources\BiciklResource\Pages;
use App\Filament\Resources\BiciklResource;
use App\Filament\Resources\BiciklAktivniResource;
use App\Filament\Resources\BiciklArhivaResource;
use App\Models\Bicikl;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
class ListBicikls extends ListRecords
{
protected static string $resource = BiciklResource::class;
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
];
}
protected function getTableRecordsPerPageSelectOptions(): array
{
return [12, 24, 48, 96, -1];
}
protected function getTableQuery(): Builder
{
$path = request()->getPathInfo();
if ($path === '/admin/bicikli-aktivni') {
return parent::getTableQuery()->where('pCena', null);
} else if ( $path === '/admin/bicikli-arhiva' ) {
return parent::getTableQuery()->whereNotNull('pCena');
} else {
return parent::getTableQuery()->withoutGlobalScopes();
}
}
}
But, even I changed tables in my Resources, they all look like one in BiciklResource. That's probably becuase of this line protected static string $resource = BiciklResource::class;
Can I set this conditionally too or there is another way?