120 lines
2.8 KiB
PHP
120 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\EmployeeStats;
|
|
|
|
use App\Enums\NavigationGroup;
|
|
use App\Filament\Concerns\HasHrResourceLabels;
|
|
use App\Filament\Resources\EmployeeStats\Pages\ListEmployeeStats;
|
|
use App\Filament\Resources\EmployeeStats\Tables\EmployeeStatsTable;
|
|
use App\Models\Employee;
|
|
use BackedEnum;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use UnitEnum;
|
|
|
|
class EmployeeStatsResource extends Resource
|
|
{
|
|
use HasHrResourceLabels;
|
|
|
|
protected static ?string $model = Employee::class;
|
|
|
|
protected static function hrLabelKeys(): array
|
|
{
|
|
return [
|
|
'model' => 'employee_stat',
|
|
'plural' => 'stats',
|
|
'navigation' => 'stats',
|
|
];
|
|
}
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedChartBar;
|
|
|
|
protected static string|UnitEnum|null $navigationGroup = NavigationGroup::Employees;
|
|
|
|
protected static ?int $navigationSort = 2;
|
|
|
|
protected static ?string $slug = 'stats';
|
|
|
|
protected static ?string $recordTitleAttribute = 'full_name';
|
|
|
|
protected static bool $isGloballySearchable = false;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema;
|
|
}
|
|
|
|
public static function infolist(Schema $schema): Schema
|
|
{
|
|
return $schema;
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return EmployeeStatsTable::configure($table);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListEmployeeStats::route('/'),
|
|
];
|
|
}
|
|
|
|
public static function canViewAny(): bool
|
|
{
|
|
return Gate::check('viewAny', Employee::class);
|
|
}
|
|
|
|
public static function canView(Model $record): bool
|
|
{
|
|
return Gate::check('view', $record);
|
|
}
|
|
|
|
public static function canCreate(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public static function canEdit(Model $record): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public static function canDelete(Model $record): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public static function canForceDelete(Model $record): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public static function canRestore(Model $record): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public static function getRecordRouteBindingEloquentQuery(): Builder
|
|
{
|
|
return parent::getRecordRouteBindingEloquentQuery()
|
|
->withoutGlobalScopes([
|
|
SoftDeletingScope::class,
|
|
]);
|
|
}
|
|
}
|