98 lines
3.3 KiB
PHP
98 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Projektes\RelationManagers;
|
|
|
|
use Filament\Actions\AssociateAction;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\DissociateAction;
|
|
use Filament\Actions\DissociateBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Components\Icon;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class ProjektFileImportsRelationManager extends RelationManager
|
|
{
|
|
protected static bool $shouldRegisterNavigation = false;
|
|
|
|
protected static string $relationship = 'file_imports';
|
|
|
|
protected static ?string $title = 'Date & Dokumente';
|
|
|
|
protected static ?string $navigationLabel = 'Daten & Dokumente';
|
|
|
|
protected static ?string $modelLabel = 'Daten oder Dokumente';
|
|
|
|
protected static ?string $pluralModelLabel = 'Daten';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Select::make('type')
|
|
->required()
|
|
->options([
|
|
'player' => 'Allgemeinflächen',
|
|
'events' => 'Objekte',
|
|
'bild' => 'Begleitmaterial Bild',
|
|
'pdf' => 'Begleitmaterial PDF',
|
|
]),
|
|
|
|
FileUpload::make('file_name')
|
|
->label('Begleitmaterial')
|
|
->disk('public')
|
|
->directory(fn () => 'projekte/'.$this->getOwnerRecord())
|
|
->visibility('public')
|
|
->required()
|
|
->storeFileNamesIn('file_name_original')
|
|
->beforeContent(Icon::make('phosphor-upload'))
|
|
->belowContent(Schema::end([
|
|
'Only excel files accepted.',
|
|
'First row contains column titles.',
|
|
]))
|
|
->acceptedFileTypes([
|
|
'application/vnd.ms-excel',
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
// 'text/csv', // Optional: include if you accept CSV too
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->emptyStateHeading('Keine Daten oder Dokumente')
|
|
->emptyStateDescription('Allgmeine .')
|
|
->recordTitleAttribute('projekte_id')
|
|
->columns([
|
|
TextColumn::make('projekte_id')
|
|
->searchable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
CreateAction::make(),
|
|
AssociateAction::make(),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DissociateAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DissociateBulkAction::make(),
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|