Grundgerüst Formulare und Seeder
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contactgroups;
|
||||
|
||||
use App\Filament\Resources\Contactgroups\Pages\CreateContactgroup;
|
||||
use App\Filament\Resources\Contactgroups\Pages\EditContactgroup;
|
||||
use App\Filament\Resources\Contactgroups\Pages\ListContactgroups;
|
||||
use App\Filament\Resources\Contactgroups\Schemas\ContactgroupForm;
|
||||
use App\Filament\Resources\Contactgroups\Tables\ContactgroupsTable;
|
||||
use App\Models\Contactgroup;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContactgroupResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Contactgroup::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ContactgroupForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ContactgroupsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListContactgroups::route('/'),
|
||||
'create' => CreateContactgroup::route('/create'),
|
||||
'edit' => EditContactgroup::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contactgroups\Pages;
|
||||
|
||||
use App\Filament\Resources\Contactgroups\ContactgroupResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateContactgroup extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ContactgroupResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contactgroups\Pages;
|
||||
|
||||
use App\Filament\Resources\Contactgroups\ContactgroupResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditContactgroup extends EditRecord
|
||||
{
|
||||
protected static string $resource = ContactgroupResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contactgroups\Pages;
|
||||
|
||||
use App\Filament\Resources\Contactgroups\ContactgroupResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListContactgroups extends ListRecords
|
||||
{
|
||||
protected static string $resource = ContactgroupResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contactgroups\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ContactgroupForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contactgroups\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContactgroupsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
52
app/Filament/Resources/Contacts/ContactResource.php
Normal file
52
app/Filament/Resources/Contacts/ContactResource.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contacts;
|
||||
|
||||
use App\Filament\Resources\Contacts\Pages\CreateContact;
|
||||
use App\Filament\Resources\Contacts\Pages\EditContact;
|
||||
use App\Filament\Resources\Contacts\Pages\ListContacts;
|
||||
use App\Filament\Resources\Contacts\RelationManagers\ContactgroupsRelationManager;
|
||||
use App\Filament\Resources\Contacts\RelationManagers\ContractsRelationManager;
|
||||
use App\Filament\Resources\Contacts\Schemas\ContactForm;
|
||||
use App\Filament\Resources\Contacts\Tables\ContactsTable;
|
||||
use App\Models\Contact;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContactResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Contact::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ContactForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ContactsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListContacts::route('/'),
|
||||
'create' => CreateContact::route('/create'),
|
||||
'edit' => EditContact::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Contacts/Pages/CreateContact.php
Normal file
11
app/Filament/Resources/Contacts/Pages/CreateContact.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contacts\Pages;
|
||||
|
||||
use App\Filament\Resources\Contacts\ContactResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateContact extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ContactResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Contacts/Pages/EditContact.php
Normal file
19
app/Filament/Resources/Contacts/Pages/EditContact.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contacts\Pages;
|
||||
|
||||
use App\Filament\Resources\Contacts\ContactResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditContact extends EditRecord
|
||||
{
|
||||
protected static string $resource = ContactResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Contacts/Pages/ListContacts.php
Normal file
19
app/Filament/Resources/Contacts/Pages/ListContacts.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contacts\Pages;
|
||||
|
||||
use App\Filament\Resources\Contacts\ContactResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListContacts extends ListRecords
|
||||
{
|
||||
protected static string $resource = ContactResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/Filament/Resources/Contacts/Schemas/ContactForm.php
Normal file
20
app/Filament/Resources/Contacts/Schemas/ContactForm.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contacts\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ContactForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('type')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
42
app/Filament/Resources/Contacts/Tables/ContactsTable.php
Normal file
42
app/Filament/Resources/Contacts/Tables/ContactsTable.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contacts\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContactsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('type')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
50
app/Filament/Resources/Contracts/ContractResource.php
Normal file
50
app/Filament/Resources/Contracts/ContractResource.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contracts;
|
||||
|
||||
use App\Filament\Resources\Contracts\Pages\CreateContract;
|
||||
use App\Filament\Resources\Contracts\Pages\EditContract;
|
||||
use App\Filament\Resources\Contracts\Pages\ListContracts;
|
||||
use App\Filament\Resources\Contracts\Schemas\ContractForm;
|
||||
use App\Filament\Resources\Contracts\Tables\ContractsTable;
|
||||
use App\Models\Contract;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContractResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Contract::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ContractForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ContractsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListContracts::route('/'),
|
||||
'create' => CreateContract::route('/create'),
|
||||
'edit' => EditContract::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Contracts/Pages/CreateContract.php
Normal file
11
app/Filament/Resources/Contracts/Pages/CreateContract.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contracts\Pages;
|
||||
|
||||
use App\Filament\Resources\Contracts\ContractResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateContract extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ContractResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Contracts/Pages/EditContract.php
Normal file
19
app/Filament/Resources/Contracts/Pages/EditContract.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contracts\Pages;
|
||||
|
||||
use App\Filament\Resources\Contracts\ContractResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditContract extends EditRecord
|
||||
{
|
||||
protected static string $resource = ContractResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Contracts/Pages/ListContracts.php
Normal file
19
app/Filament/Resources/Contracts/Pages/ListContracts.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contracts\Pages;
|
||||
|
||||
use App\Filament\Resources\Contracts\ContractResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListContracts extends ListRecords
|
||||
{
|
||||
protected static string $resource = ContractResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Filament/Resources/Contracts/Schemas/ContractForm.php
Normal file
34
app/Filament/Resources/Contracts/Schemas/ContractForm.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contracts\Schemas;
|
||||
|
||||
use App\Models\Contact;
|
||||
use App\Models\User;
|
||||
use Filament\Forms\Components\MorphToSelect;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ContractForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('type')
|
||||
->required(),
|
||||
Select::make('responsible_id')
|
||||
->relationship('responsible', 'name')
|
||||
->required(),
|
||||
MorphToSelect::make('contractable')
|
||||
->types([
|
||||
MorphToSelect\Type::make(User::class)
|
||||
->titleAttribute('name'),
|
||||
MorphToSelect\Type::make(Contact::class)
|
||||
->titleAttribute('name'),
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
49
app/Filament/Resources/Contracts/Tables/ContractsTable.php
Normal file
49
app/Filament/Resources/Contracts/Tables/ContractsTable.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Contracts\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContractsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('type')
|
||||
->searchable(),
|
||||
TextColumn::make('responsible.name')
|
||||
->searchable(),
|
||||
TextColumn::make('contractable_type')
|
||||
->searchable(),
|
||||
TextColumn::make('contractable_id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
50
app/Filament/Resources/Documents/DocumentResource.php
Normal file
50
app/Filament/Resources/Documents/DocumentResource.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Documents;
|
||||
|
||||
use App\Filament\Resources\Documents\Pages\CreateDocument;
|
||||
use App\Filament\Resources\Documents\Pages\EditDocument;
|
||||
use App\Filament\Resources\Documents\Pages\ListDocuments;
|
||||
use App\Filament\Resources\Documents\Schemas\DocumentForm;
|
||||
use App\Filament\Resources\Documents\Tables\DocumentsTable;
|
||||
use App\Models\Document;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class DocumentResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Document::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return DocumentForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return DocumentsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListDocuments::route('/'),
|
||||
'create' => CreateDocument::route('/create'),
|
||||
'edit' => EditDocument::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Documents/Pages/CreateDocument.php
Normal file
11
app/Filament/Resources/Documents/Pages/CreateDocument.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Documents\Pages;
|
||||
|
||||
use App\Filament\Resources\Documents\DocumentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDocument extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DocumentResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Documents/Pages/EditDocument.php
Normal file
19
app/Filament/Resources/Documents/Pages/EditDocument.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Documents\Pages;
|
||||
|
||||
use App\Filament\Resources\Documents\DocumentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditDocument extends EditRecord
|
||||
{
|
||||
protected static string $resource = DocumentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Documents/Pages/ListDocuments.php
Normal file
19
app/Filament/Resources/Documents/Pages/ListDocuments.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Documents\Pages;
|
||||
|
||||
use App\Filament\Resources\Documents\DocumentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListDocuments extends ListRecords
|
||||
{
|
||||
protected static string $resource = DocumentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Filament/Resources/Documents/Schemas/DocumentForm.php
Normal file
23
app/Filament/Resources/Documents/Schemas/DocumentForm.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Documents\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class DocumentForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('documentable_type')
|
||||
->required(),
|
||||
TextInput::make('documentable_id')
|
||||
->required()
|
||||
->numeric(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
45
app/Filament/Resources/Documents/Tables/DocumentsTable.php
Normal file
45
app/Filament/Resources/Documents/Tables/DocumentsTable.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Documents\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class DocumentsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('documentable_type')
|
||||
->searchable(),
|
||||
TextColumn::make('documentable_id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\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\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class DocumentsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'documents';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('documentable_type')
|
||||
->required(),
|
||||
TextInput::make('documentable_id')
|
||||
->required()
|
||||
->numeric(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('name')
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('documentable_type')
|
||||
->searchable(),
|
||||
TextColumn::make('documentable_id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
AssociateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DissociateAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DissociateBulkAction::make(),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace App\Filament\Resources\Users;
|
||||
use App\Filament\Resources\Users\Pages\CreateUser;
|
||||
use App\Filament\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Resources\Users\Pages\ListUsers;
|
||||
use App\Filament\Resources\Users\RelationManagers\ContractsRelationManager;
|
||||
use App\Filament\Resources\Users\RelationManagers\DocumentsRelationManager;
|
||||
use App\Filament\Resources\Users\Schemas\UserForm;
|
||||
use App\Filament\Resources\Users\Tables\UsersTable;
|
||||
use App\Models\User;
|
||||
|
||||
15
app/HasContactgroups.php
Normal file
15
app/HasContactgroups.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Models\Contactgroup;
|
||||
use App\Models\Document;
|
||||
|
||||
trait HasContactgroups
|
||||
{
|
||||
public function contactgroups()
|
||||
{
|
||||
return $this->morphToMany(Contactgroup::class, 'contactgroupable');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\Contract;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
trait HasContracts
|
||||
{
|
||||
public function contracts()
|
||||
public function contracts(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'contractable');
|
||||
return $this->morphMany(Contract::class, 'contractable');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\HasContactgroups;
|
||||
use App\HasContracts;
|
||||
use App\HasDocuments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
use HasDocuments, HasContracts;
|
||||
use HasContactgroups;
|
||||
|
||||
protected $fillable = ['name', 'type'];
|
||||
|
||||
|
||||
19
app/Models/Contactgroup.php
Normal file
19
app/Models/Contactgroup.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Contactgroup extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['name', 'type'];
|
||||
|
||||
public function contactgroupable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,16 +4,23 @@ namespace App\Models;
|
||||
|
||||
use App\HasDocuments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Contract extends Model
|
||||
{
|
||||
use HasDocuments;
|
||||
|
||||
protected $fillable = ['name', 'type'];
|
||||
protected $fillable = ['name', 'type', 'responsible_id', 'contractable_type', 'contractable_id'];
|
||||
|
||||
public function contractable()
|
||||
public function contractable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function responsible(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
10
app/Models/Documentpermission.php
Normal file
10
app/Models/Documentpermission.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Documentpermission extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -4,8 +4,11 @@ namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
|
||||
use App\HasContactgroups;
|
||||
use App\HasContracts;
|
||||
use App\HasDocuments;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
@@ -13,7 +16,8 @@ class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
use HasDocuments;
|
||||
use HasContactgroups;
|
||||
use HasContracts;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -16,8 +16,9 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->foreignIdFor(User::class, 'responsible');
|
||||
$table->morphs('contractable');
|
||||
$table->foreignIdFor(User::class, 'responsible_id');
|
||||
$table->integer('contractable_id')->nullable();
|
||||
$table->string('contractable_type')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('documentpermissions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string("type");
|
||||
$table->string("class");
|
||||
$table->string("acl");
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('documentpermissions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('contactgroups', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contactgroups');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('contactgroupables', function (Blueprint $table) {
|
||||
$table->foreignId('contactgroup_id')->constrained();
|
||||
$table->morphs('contactgroupable');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contactgroupables');
|
||||
}
|
||||
};
|
||||
28
database/seeders/ContactgroupSeeder.php
Normal file
28
database/seeders/ContactgroupSeeder.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Contactgroup;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ContactgroupSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$contactgroups = [
|
||||
'Personalabteilung',
|
||||
'Geschäftsführung',
|
||||
'Support',
|
||||
'Entwicklung',
|
||||
'Finanzen',
|
||||
];
|
||||
foreach ($contactgroups as $contactgroup) {
|
||||
Contactgroup::firstOrCreate(['name' => $contactgroup]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,15 @@ class DatabaseSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
|
||||
User::firstOrCreate(
|
||||
['email' => 'info@geoventis.de'],
|
||||
[
|
||||
'name' => 'Max Mustermann',
|
||||
'password' => bcrypt('servo3000'),
|
||||
]
|
||||
);
|
||||
$this->call([
|
||||
UserSeeder::class,
|
||||
DocumentpermissionSeeder::class,
|
||||
ContactgroupSeeder::class,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
22
database/seeders/DocumentpermissionSeeder.php
Normal file
22
database/seeders/DocumentpermissionSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DocumentpermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('documentpermissions')->insert([
|
||||
'type' => 'Krankmeldung',
|
||||
'class' => 'App\Models\User',
|
||||
'acl' => 'default:|self:cr|memberOf(contactgroups.Personalabteilung)',
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
database/seeders/UserSeeder.php
Normal file
31
database/seeders/UserSeeder.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
User::firstOrCreate(
|
||||
['email' => 'info@geoventis.de'],
|
||||
[
|
||||
'name' => 'Max Mustermann',
|
||||
'password' => bcrypt('servo3000'),
|
||||
]
|
||||
);
|
||||
User::firstOrCreate(
|
||||
['email' => 'alexander.gabriel@digital-infinity.de'],
|
||||
[
|
||||
'name' => 'Alexander Gabriel',
|
||||
'password' => bcrypt('servo3000'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user