where("role", "student")->where("school_id", auth()->user()->school_id); } /** * @throws Exception */ public static function table(Table $table): Table { return $table ->headerActions([ ImportAction::make() ->importer(UserImporter::class) ]) ->bulkActions([ ExportBulkAction::make() ->exporter(UserExporter::class) ->formats([ ExportFormat::Xlsx, ]) ]) ->columns([ Tables\Columns\TextColumn::make("name")->label(__("user-resource.name"))->searchable(), Tables\Columns\TextColumn::make('grade')->label(__("user-resource.grade"))->searchable(), Tables\Columns\TextColumn::make('iin')->label(__("user-resource.iin"))->searchable(), ]) ->paginated([20]) ->filters([ Tables\Filters\SelectFilter::make('grade') ->label(__('user-resource.grade')) ->options([ '1В' => '1В', '2Г' => '2Г', '30' => '30', '40' => '40', '50' => '50', '60' => '60', '70' => '70', ]), ]) ->actions([ Tables\Actions\EditAction::make()->hiddenLabel(), Tables\Actions\DeleteAction::make()->hiddenLabel(), Action::make('Scan card') ->hiddenLabel() ->icon('heroicon-o-credit-card') ->modalContent(function ($record) { return view('filament.pages.show-user-cards', ['userId' => $record->id]); }), ]); } public static function form(Form $form): Form { return $form ->schema([ Forms\Components\TextInput::make('name') ->label(__('user-resource.name')) ->required() ->maxLength(255), Forms\Components\TextInput::make('username') ->label(__('user-resource.username')) ->required() ->maxLength(255), Forms\Components\TextInput::make('status') ->label(__('user-resource.status')) ->required() ->maxLength(255) ->default('active'), Forms\Components\TextInput::make('email') ->label(__('user-resource.email')) ->email() ->maxLength(255), Forms\Components\TextInput::make('password') ->label(__('user-resource.password')) ->password() ->required() ->maxLength(255), Forms\Components\Toggle::make('free') ->label(__('user-resource.free')) ->required(), Forms\Components\TextInput::make('grade') ->label(__('user-resource.grade')) ->maxLength(255), Forms\Components\TextInput::make('balance') ->label(__('user-resource.balance')) ->required() ->numeric() ->default(0), Forms\Components\TextInput::make('phone') ->label(__('user-resource.phone')) ->tel() ->maxLength(255), Forms\Components\Hidden::make('school_id') ->default(auth()->user()->school_id), ]); } public static function getModelLabel(): string { return __('user-resource.user'); } public static function getPluralModelLabel(): string { return __('user-resource.users'); } public static function getPages(): array { return [ 'index' => Pages\ListUsers::route('/'), // 'create' => Pages\CreateUser::route('/create'), // 'edit' => Pages\EditUser::route('/{record}/edit'), ]; } }