Mache Medien, Übungen und Kurse in der Verwaltung bearbeitbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4f2e5a5f3b
commit
3ee9f529ca
33 files changed
+1105
-284
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Compositions;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
abstract class CompositionKindResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Composition::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'designation';
|
||||
|
||||
abstract public static function kind(): CompositionKind;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return ContentElementResource::editor();
|
||||
}
|
||||
|
||||
public static function getEditAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return ContentElementResource::editor() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('designation')->label('Bezeichnung')->searchable(),
|
||||
TextColumn::make('versions_count')->counts('versions')->label('Fassungen'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('kind', static::kind());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user