Grundgerüst Formulare und Seeder
This commit is contained in:
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user