Linux sg77.dns-private.com 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
LiteSpeed
Server IP : 135.181.230.13 & Your IP : 216.73.216.199
Domains :
Cant Read [ /etc/named.conf ]
User : pilasate
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
pilasate /
schoolms /
app /
Filament /
Resources /
Delete
Unzip
Name
Size
Permission
Date
Action
AttendanceResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
CourseAssignmentResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
CourseEnrollmentResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
GradeResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
MarkResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
MessageResource
[ DIR ]
drwxr-xr-x
2025-03-27 22:56
PromotionResource
[ DIR ]
drwxrwxrwx
2025-03-24 00:50
ReportResource
[ DIR ]
drwxrwxrwx
2025-03-24 10:11
StudentResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
SubjectResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
TeacherResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
UserResource
[ DIR ]
drwxrwxrwx
2025-03-23 13:10
Widgets
[ DIR ]
drwxrwxrwx
2025-03-23 19:51
AttendanceResource.php
13.87
KB
-rw-rw-rw-
2025-03-24 07:12
CourseAssignmentResource.php
7.36
KB
-rw-rw-rw-
2025-03-27 22:46
CourseEnrollmentResource.php
15.35
KB
-rw-rw-rw-
2025-03-24 06:07
GradeResource.php
3.48
KB
-rw-rw-rw-
2025-03-24 06:33
MarkResource.php
17.63
KB
-rw-rw-rw-
2025-03-28 00:00
MessageResource.php
5.43
KB
-rw-r--r--
2025-03-28 00:04
PromotionResource.php
8.05
KB
-rw-rw-rw-
2025-03-24 03:04
StudentResource.php
5.58
KB
-rw-rw-rw-
2025-03-27 22:49
SubjectResource.php
2.81
KB
-rw-rw-rw-
2025-03-24 11:32
TeacherResource.php
3.92
KB
-rw-rw-rw-
2025-03-24 11:32
UserResource.php
4.91
KB
-rw-rw-rw-
2025-03-24 06:45
Save
Rename
<?php namespace App\Filament\Resources; use App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource\RelationManagers; use App\Models\User; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Support\Facades\Auth; class UserResource extends Resource { protected static ?string $model = User::class; protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; protected static ?string $navigationGroup = 'User Management'; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\TextInput::make('name') ->placeholder('Full Name') ->required(), Forms\Components\TextInput::make('email') ->email() ->required(), Forms\Components\TextInput::make('password') ->revealable() ->password() ->placeholder('Password') ->required(fn ($operation) => $operation === 'create') // Only required on create ->dehydrated(fn ($state) => filled($state)), // Only save if filled Forms\Components\Select::make('roles') ->relationship('roles', 'name') // Links to the roles relationship ->getOptionLabelFromRecordUsing(fn ($record) => $record->name) // Explicitly set the label // ->multiple() // Allow multiple role assignments (optional, uncomment if needed) ->preload() // Preload existing roles ->native(false) // Use Filament's custom select component // ->columnSpanFull() ->required(), // Enforce role selection ])->columns(3); } public static function table(Table $table): Table { return $table // ->query(User::with('roles')) // Eager load roles ->columns([ Tables\Columns\TextColumn::make('name') ->sortable() ->searchable(), Tables\Columns\TextColumn::make('email') ->sortable() ->searchable(), Tables\Columns\TextColumn::make('roles.name') ->label('Role') ->formatStateUsing(fn ($state) => ucfirst($state ?? 'None')) ->sortable(), ]) ->groups([ Tables\Grouping\Group::make('roles.name') ->label('Users by Role') ->collapsible() // Mimics a section that can be expanded/collapsed ->titlePrefixedWithLabel(false) // Shows just "Admin," "Teacher," etc. ->getTitleFromRecordUsing(fn (User $record) => ucfirst($record->roles->first()->name ?? 'No Role')), ]) ->defaultGroup('roles.name') // Automatically group by role on load ->defaultSort('name') ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } 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'), ]; } public static function canViewAny(): bool { return Auth::user()->hasRole('admin'); } public static function canCreate(): bool { return Auth::user()->hasRole(['admin', 'teacher']); } public static function canEdit($record): bool { $user = Auth::user(); // Allow admins to edit any record // Allow teachers to edit only their own records return $user->hasRole('admin') || ($user->hasRole('teacher') && $record->teacher_id === $user->id); } public static function canDelete($record): bool { return Auth::user()->hasRole('admin'); } public static function getNavigationBadge(): ?string { $user = Auth::user(); if ($user->hasRole('admin')) { // Total teachers (users with 'teacher' role) $totalTeachers = User::role(['teacher', 'admin', 'student'])->count(); return (string) $totalTeachers; } // Default to 0 for other roles return (string) 0; } }