user()->can('manage_users') || auth()->user()->can('admin'); } protected static ?string $model = User::class; protected static ?string $navigationIcon = 'heroicon-o-users'; protected static ?string $navigationGroup = 'Ustawienia'; protected static ?string $modelLabel = 'Administrator'; protected static ?string $pluralModelLabel = 'Administratorzy'; protected static ?int $navigationSort = 1; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Section::make('Dane użytkownika') ->schema([ TextInput::make('name') ->label('Nazwa użytkownika') ->required(), TextInput::make('email') ->label('Adres e-mail') ->email() ->required(), TextInput::make('password') ->label('Hasło') ->password() ->required(fn ($livewire) => $livewire instanceof \Filament\Resources\Pages\CreateRecord) ->dehydrated(fn ($state) => filled($state)) ->dehydrateStateUsing(fn ($state) => bcrypt($state)), Select::make('roles') ->label('Role') ->relationship('roles', 'name') ->multiple() ->preload() ->searchable(), ]) ->columns(2) ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->label('Użytkownik')->searchable(), TextColumn::make('email')->label('E-mail')->searchable(), TagsColumn::make('roles.name')->label('Role'), TextColumn::make('created_at')->label('Data utworzenia')->dateTime(), ]) ->description('Dodawaj lub edytuj administratorów.') ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ // ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListUsers::route('/'), 'create' => Pages\CreateUser::route('/create'), 'edit' => Pages\EditUser::route('/{record}/edit'), ]; } }