Files
laraundfelix/app/Filament/Resources/LicenseArticles/LicenseArticleResource.php
T
LarsandCursor f29ea58fd5
CI Feature / test (push) Successful in 54s
Deploy Test / test (push) Successful in 47s
Deploy Test / deploy (push) Successful in 24s
Ergänze die gemeinsame redaktionelle Basis an den Fachobjekten.
Texte, Materialart und Präsentationsmedien bleiben am Medium, Modul, Programm und Lizenzartikel und werden von Verwaltung und Karten aus derselben Quelle gelesen, ohne Fassung oder Lizenz zu verändern.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 07:54:36 +01:00

92 lines
3.0 KiB
PHP

<?php
namespace App\Filament\Resources\LicenseArticles;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Identity\StaffRole;
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
use App\Filament\Support\CatalogReading;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Infolists\Components\TextEntry;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Auth\Access\Response;
use Illuminate\Database\Eloquent\Model;
class LicenseArticleResource extends Resource
{
protected static ?string $model = LicenseArticle::class;
protected static string|\UnitEnum|null $navigationGroup = 'Katalog';
protected static ?string $navigationLabel = 'Lizenzartikel';
protected static ?string $modelLabel = 'Lizenzartikel';
protected static ?string $pluralModelLabel = 'Lizenzartikel';
protected static ?string $recordTitleAttribute = 'code';
protected static ?int $navigationSort = 1;
public static function canViewAny(): bool
{
return self::keeper();
}
public static function keeper(): bool
{
$user = Filament::auth()->user();
return $user instanceof User && $user->hasStaffRole(StaffRole::Katalogverwalter);
}
public static function getViewAuthorizationResponse(Model $record): Response
{
return self::keeper() ? Response::allow() : Response::deny();
}
public static function infolist(Schema $schema): Schema
{
return $schema->components([
Section::make('Aktueller Stand')->schema([
TextEntry::make('stand')->hiddenLabel()->listWithLineBreaks()
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleStand($record)),
]),
Section::make('Pakete und Angebote')->description('Wo dieser Artikel lizenziert wird.')->schema([
TextEntry::make('context')->hiddenLabel()->listWithLineBreaks()
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleContext($record)),
]),
View::make('filament.editorial.license-desk'),
]);
}
public static function form(Schema $schema): Schema
{
return $schema;
}
public static function table(Table $table): Table
{
return $table->columns([
TextColumn::make('code')->label('Kennung')->searchable(),
TextColumn::make('product_line')->label('Produktlinie'),
TextColumn::make('currentRelease.number')->label('Aktueller Stand'),
]);
}
public static function getPages(): array
{
return [
'index' => ListLicenseArticles::route('/'),
'view' => ViewLicenseArticle::route('/{record}'),
];
}
}