Enhanced admin panel

This commit is contained in:
Constantin Graf
2024-04-29 18:46:28 +02:00
committed by Constantin Graf
parent fccd57a3f3
commit a4667589f2
8 changed files with 208 additions and 28 deletions

View File

@@ -4,10 +4,17 @@ declare(strict_types=1);
namespace App\Filament\Resources\UserResource\RelationManagers;
use Filament\Forms;
use App\Enums\Role;
use App\Filament\Resources\OrganizationResource;
use App\Models\Organization;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\AttachAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class OrganizationsRelationManager extends RelationManager
@@ -18,9 +25,12 @@ class OrganizationsRelationManager extends RelationManager
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Select::make('role')
->options(Role::class),
TextInput::make('billable_rate')
->label('Billable rate (in Cents)')
->nullable()
->numeric(),
]);
}
@@ -29,21 +39,31 @@ class OrganizationsRelationManager extends RelationManager
return $table
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
])
->filters([
//
TextColumn::make('name'),
TextColumn::make('role'),
TextColumn::make('billable_rate')
->money(fn (Organization $resource) => $resource->currency ?? 'EUR', divideBy: 100),
])
->headerActions([
Tables\Actions\CreateAction::make(),
Tables\Actions\AttachAction::make()->form(fn (AttachAction $action): array => [
$action->getRecordSelect(),
Select::make('role')
->options(Role::class),
]),
])
->actions([
Action::make('view')
->icon('heroicon-o-eye')
->color('gray')
->url(fn (Organization $record): string => OrganizationResource::getUrl('view', [
'record' => $record->getKey(),
])),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Tables\Actions\DetachAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\DetachBulkAction::make(),
]),
]);
}