mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 13:32:43 +01:00
99 lines
3.0 KiB
PHP
99 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\UserResource\Pages;
|
|
use App\Filament\Resources\UserResource\RelationManagers\OrganizationsRelationManager;
|
|
use App\Filament\Resources\UserResource\RelationManagers\OwnedOrganizationsRelationManager;
|
|
use App\Models\User;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class UserResource extends Resource
|
|
{
|
|
protected static ?string $model = User::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-user';
|
|
|
|
protected static ?string $navigationGroup = 'Users';
|
|
|
|
protected static ?int $navigationSort = 6;
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->columns(1)
|
|
->schema([
|
|
Forms\Components\TextInput::make('id')
|
|
->label('ID')
|
|
->disabled()
|
|
->visibleOn(['update', 'show'])
|
|
->readOnly()
|
|
->maxLength(255),
|
|
Forms\Components\TextInput::make('name')
|
|
->label('Name')
|
|
->required()
|
|
->maxLength(255),
|
|
Forms\Components\TextInput::make('email')
|
|
->label('Email')
|
|
->required()
|
|
->maxLength(255),
|
|
TextInput::make('password')
|
|
->password()
|
|
->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
|
->dehydrated(fn ($state) => filled($state))
|
|
->required(fn (string $context): bool => $context === 'create')
|
|
->maxLength(255),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('email')
|
|
->icon('heroicon-m-envelope')
|
|
->searchable()
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
OwnedOrganizationsRelationManager::class,
|
|
OrganizationsRelationManager::class,
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListUsers::route('/'),
|
|
'create' => Pages\CreateUser::route('/create'),
|
|
'edit' => Pages\EditUser::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|