todos angelegt
This commit is contained in:
1 parent
19a62578fb
commit
cf2c953fab
9 files changed
+271
No files matched your search
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Todos\Pages;
|
||||
|
||||
use App\Filament\Resources\Todos\TodoResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTodo extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TodoResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Todos\Pages;
|
||||
|
||||
use App\Filament\Resources\Todos\TodoResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTodo extends EditRecord
|
||||
{
|
||||
protected static string $resource = TodoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Todos\Pages;
|
||||
|
||||
use App\Filament\Resources\Todos\TodoResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTodos extends ListRecords
|
||||
{
|
||||
protected static string $resource = TodoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Todos\Schemas;
|
||||
|
||||
use App\Models\Group;
|
||||
use App\Models\User;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\MorphToSelect;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\RichEditor\RichEditorTool;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Random\Engine\Secure;
|
||||
|
||||
class TodoForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Titel')
|
||||
->required(),
|
||||
Select::make('user.name')->relationship('user', 'name')->label('Benutzer')->hiddenOn(['create'])->disabledOn(['edit']),
|
||||
Hidden::make('user_id')->default(filament()->auth()->user()->id),
|
||||
RichEditor::make('content')
|
||||
->label('Todo')
|
||||
->columnSpanFull(),
|
||||
MorphToSelect::make('todoable')
|
||||
->types([
|
||||
MorphToSelect\Type::make(User::class)->label('Benutzer')->titleAttribute('name'),
|
||||
MorphToSelect\Type::make(Group::class)->label('Gruppe')->titleAttribute('name'),
|
||||
])
|
||||
->label('zugeordnet'),
|
||||
Section::make()->components([
|
||||
DatePicker::make('due_date')->label('Todo-Datum'),
|
||||
Toggle::make('review')->label('Review')->hint('Todo geht nach Erledigung noch mal zum Ersteller'),
|
||||
|
||||
]),
|
||||
DatePicker::make('follow_up')->label('Wiedervorlage/Erinnerung'),
|
||||
DatePicker::make('done_date')->label('Erledigt am')->hiddenOn(['create']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Todos\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TodosTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('user.name')
|
||||
->searchable(),
|
||||
TextColumn::make('todoable.name')
|
||||
->label('Zugewiesen')
|
||||
->searchable(),
|
||||
TextColumn::make('due_date')
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('done_date')
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('follow_up')
|
||||
->date()
|
||||
->sortable(),
|
||||
IconColumn::make('review')
|
||||
->boolean(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Todos;
|
||||
|
||||
use App\Filament\Resources\Todos\Pages\CreateTodo;
|
||||
use App\Filament\Resources\Todos\Pages\EditTodo;
|
||||
use App\Filament\Resources\Todos\Pages\ListTodos;
|
||||
use App\Filament\Resources\Todos\Schemas\TodoForm;
|
||||
use App\Filament\Resources\Todos\Tables\TodosTable;
|
||||
use App\Models\Todo;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TodoResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Todo::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TodoForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TodosTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTodos::route('/'),
|
||||
'create' => CreateTodo::route('/create'),
|
||||
'edit' => EditTodo::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user