up
This commit is contained in:
@@ -7,6 +7,7 @@ use Filament\Actions;
|
|||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Filament\Resources\Components\Tab;
|
||||||
|
|
||||||
class ListOjalPresillas extends ListRecords
|
class ListOjalPresillas extends ListRecords
|
||||||
{
|
{
|
||||||
@@ -20,9 +21,33 @@ class ListOjalPresillas extends ListRecords
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTabs(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'todos' => Tab::make('Todos')
|
||||||
|
->badge(
|
||||||
|
\App\Models\Ojal::count() + \App\Models\Prensilla::count()
|
||||||
|
),
|
||||||
|
'ojales' => Tab::make('Ojales')
|
||||||
|
->badge(\App\Models\Ojal::count())
|
||||||
|
->modifyQueryUsing(fn ($query) => $query),
|
||||||
|
'prensillas' => Tab::make('Prensillas')
|
||||||
|
->badge(\App\Models\Prensilla::count())
|
||||||
|
->modifyQueryUsing(fn ($query) => $query->whereRaw('1=0')), // Vacío por defecto
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
protected function getTableQuery(): ?\Illuminate\Database\Eloquent\Builder
|
protected function getTableQuery(): ?\Illuminate\Database\Eloquent\Builder
|
||||||
{
|
{
|
||||||
// Solo mostrar ojales (los otros recursos muestran prensillas)
|
$activeTab = $this->activeTab ?? 'todos';
|
||||||
|
|
||||||
|
// Siempre retornar ojales como base, pero ajustar qué se muestra
|
||||||
|
if ($activeTab === 'prensillas') {
|
||||||
|
// Para mostrar prensillas, necesitamos cambiar el modelo dinámicamente
|
||||||
|
// Por limitaciones de Filament, mantener ojales pero filtrar a ninguno
|
||||||
|
return \App\Models\Ojal::query()->whereRaw('1=0');
|
||||||
|
}
|
||||||
|
|
||||||
return \App\Models\Ojal::query();
|
return \App\Models\Ojal::query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,4 +62,9 @@ class ListOjalPresillas extends ListRecords
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return \App\Filament\Resources\PrensillaResource::getUrl('edit', ['record' => $record]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class OjalResource extends Resource
|
|||||||
protected static ?string $navigationGroup = 'Gestión';
|
protected static ?string $navigationGroup = 'Gestión';
|
||||||
protected static ?string $navigationLabel = 'Ojales';
|
protected static ?string $navigationLabel = 'Ojales';
|
||||||
protected static ?int $navigationSort = 4;
|
protected static ?int $navigationSort = 4;
|
||||||
protected static bool $shouldRegisterNavigation = false;
|
|
||||||
|
|
||||||
public static function canViewAny(): bool
|
public static function canViewAny(): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class PrensillaResource extends Resource
|
|||||||
protected static ?string $navigationGroup = 'Gestión';
|
protected static ?string $navigationGroup = 'Gestión';
|
||||||
protected static ?string $navigationLabel = 'Prensillas';
|
protected static ?string $navigationLabel = 'Prensillas';
|
||||||
protected static ?int $navigationSort = 5;
|
protected static ?int $navigationSort = 5;
|
||||||
protected static bool $shouldRegisterNavigation = false;
|
|
||||||
|
|
||||||
public static function canViewAny(): bool
|
public static function canViewAny(): bool
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user