76 lines
2.4 KiB
PHP
76 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\RightsProfiles;
|
|
|
|
use App\Domain\Catalog\RightsProfile;
|
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
|
use App\Filament\Resources\RightsProfiles\Pages\ListRightsProfiles;
|
|
use App\Filament\Resources\RightsProfiles\Pages\ViewRightsProfile;
|
|
use App\Filament\Support\CatalogReading;
|
|
use Filament\Infolists\Components\TextEntry;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Auth\Access\Response;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class RightsProfileResource extends Resource
|
|
{
|
|
protected static ?string $model = RightsProfile::class;
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Katalog';
|
|
|
|
protected static ?string $navigationLabel = 'Rechteprofile';
|
|
|
|
protected static ?string $modelLabel = 'Rechteprofil';
|
|
|
|
protected static ?string $pluralModelLabel = 'Rechteprofile';
|
|
|
|
protected static ?string $recordTitleAttribute = 'name';
|
|
|
|
protected static ?int $navigationSort = 3;
|
|
|
|
public static function canViewAny(): bool
|
|
{
|
|
return LicenseArticleResource::keeper();
|
|
}
|
|
|
|
public static function getViewAuthorizationResponse(Model $record): Response
|
|
{
|
|
return LicenseArticleResource::keeper() ? Response::allow() : Response::deny();
|
|
}
|
|
|
|
public static function infolist(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Section::make('Fähigkeiten')->description('Zweck und erlaubte Handlungen. Angebote verwenden diese Fassung.')->schema([
|
|
TextEntry::make('rights')->hiddenLabel()->listWithLineBreaks()
|
|
->state(fn (RightsProfile $record): array => app(CatalogReading::class)->rights($record)),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema;
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table->columns([
|
|
TextColumn::make('name')->label('Name')->searchable(),
|
|
TextColumn::make('versions.purpose')->label('Zwecke')->badge(),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListRightsProfiles::route('/'),
|
|
'view' => ViewRightsProfile::route('/{record}'),
|
|
];
|
|
}
|
|
}
|