mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\OrganizationResource\Pages;
|
|
use App\Models\Organization;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class OrganizationResource extends Resource
|
|
{
|
|
protected static ?string $model = Organization::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-building-office-2';
|
|
|
|
protected static ?string $navigationGroup = 'Users';
|
|
|
|
protected static ?int $navigationSort = 7;
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->columns(1)
|
|
->schema([
|
|
Forms\Components\TextInput::make('name')
|
|
->label('Name')
|
|
->required()
|
|
->maxLength(255),
|
|
Forms\Components\Toggle::make('personal_team')
|
|
->label('Is personal?')
|
|
->required(),
|
|
Forms\Components\Select::make('user_id')
|
|
->relationship(name: 'owner', titleAttribute: 'email')
|
|
->searchable(['name', 'email'])
|
|
->required(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\IconColumn::make('personal_team')
|
|
->boolean()
|
|
->label('Is personal?')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('owner.email')
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListOrganizations::route('/'),
|
|
'create' => Pages\CreateOrganization::route('/create'),
|
|
'edit' => Pages\EditOrganization::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|