schema([ TextInput::make(UserModel::ATTRIBUTE_NAME) ->label(__('filament.fields.user.name')) ->required() ->maxLength(192) ->rules(['required', 'max:192']), TextInput::make(UserModel::ATTRIBUTE_EMAIL) ->label(__('filament.fields.user.email')) ->email() ->required() ->maxLength(192) ->rules(['required', 'email', 'max:192']), ]) ->columns(1); } /** * The index page of the resource. * * @param Table $table * @return Table * * @noinspection PhpMissingParentCallCommonInspection */ public static function table(Table $table): Table { return parent::table($table) ->columns([ TextColumn::make(UserModel::ATTRIBUTE_ID) ->label(__('filament.fields.base.id')) ->sortable(), ImageColumn::make('avatar') ->label(__('filament.fields.user.avatar')) ->defaultImageUrl(fn (UserModel $model) => $model->getFilamentAvatarUrl()) ->circular(), TextColumn::make(UserModel::ATTRIBUTE_NAME) ->label(__('filament.fields.user.name')) ->sortable() ->searchable() ->copyableWithMessage() ->toggleable(), TextColumn::make(UserModel::ATTRIBUTE_EMAIL) ->label(__('filament.fields.user.email')) ->icon('heroicon-m-envelope') ->toggleable(), ]); } /** * Get the infolist available for the resource. * * @param Infolist $infolist * @return Infolist * * @noinspection PhpMissingParentCallCommonInspection */ public static function infolist(Infolist $infolist): Infolist { return $infolist ->schema([ Section::make(static::getRecordTitle($infolist->getRecord())) ->schema([ ImageEntry::make('avatar') ->label(__('filament.fields.user.avatar')) ->defaultImageUrl(fn (UserModel $model) => $model->getFilamentAvatarUrl()) ->circular(), TextEntry::make(UserModel::ATTRIBUTE_NAME) ->label(__('filament.fields.user.name')) ->copyableWithMessage(), TextEntry::make(UserModel::ATTRIBUTE_EMAIL) ->label(__('filament.fields.user.email')) ->icon('heroicon-m-envelope'), TextEntry::make(UserModel::ATTRIBUTE_ID) ->label(__('filament.fields.base.id')), ]) ->columns(3), Section::make(__('filament.fields.base.timestamps')) ->schema(parent::timestamps()) ->columns(3), ]); } /** * Get the relationships available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getRelations(): array { return [ RelationGroup::make(static::getLabel(), array_merge( [ RoleUserRelationManager::class, PermissionUserRelationManager::class, PlaylistUserRelationManager::class, ], parent::getBaseRelations(), ) ), ]; } /** * Get the filters available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getFilters(): array { return []; } /** * Get the actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getActions(): array { return array_merge( parent::getActions(), [ ActionGroup::make([ GiveRoleAction::make('give-role'), RevokeRoleAction::make('revoke-role'), GivePermissionAction::make('give-permission'), RevokePermissionAction::make('revoke-permission'), ]), ], ); } /** * Get the bulk actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getBulkActions(): array { return array_merge( parent::getBulkActions(), [], ); } /** * Get the header actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getHeaderActions(): array { return array_merge( parent::getHeaderActions(), [], ); } /** * Get the pages available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getPages(): array { return [ 'index' => ListUsers::route('/'), 'create' => CreateUser::route('/create'), 'view' => ViewUser::route('/{record:id}'), 'edit' => EditUser::route('/{record:id}/edit'), ]; } }