diff --git a/app/Filament/Resources/PengumumanResource.php b/app/Filament/Resources/PengumumanResource.php index cf50baa3..a1e9ac61 100644 --- a/app/Filament/Resources/PengumumanResource.php +++ b/app/Filament/Resources/PengumumanResource.php @@ -10,6 +10,7 @@ use Filament\Tables\Table; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\ViewColumn; +use Illuminate\Database\Eloquent\Builder; // Add this line class PengumumanResource extends Resource { @@ -20,7 +21,7 @@ class PengumumanResource extends Resource protected static ?string $navigationLabel = 'Pengumuman'; protected static ?int $navigationSort = 3; protected static ?string $slug = 'pengumuman'; - + protected static ?string $modelLabel = 'Pengumuman'; protected static ?string $pluralModelLabel = 'Pengumuman'; protected static ?string $breadcrumb = 'Pengumuman'; @@ -33,7 +34,7 @@ public static function table(Table $table): Table ->label('Nama Mahasiswa') ->searchable() ->sortable(), - + TextColumn::make('status') ->label('Status Berkas') ->badge() @@ -43,7 +44,7 @@ public static function table(Table $table): Table 'belum_validasi' => 'warning', default => 'gray', }), - + TextColumn::make('hasil') ->label('Hasil Seleksi') ->badge() @@ -53,12 +54,19 @@ public static function table(Table $table): Table 'Tidak Layak' => 'danger', default => 'gray', }), - + ViewColumn::make('keterangan') ->label('Keterangan') ->view('filament.tables.columns.keterangan-pengumuman'), ]) - ->defaultSort('total_nilai', 'desc'); + ->defaultSort('total_nilai', 'desc') + ->modifyQueryUsing(function (Builder $query): Builder { + $user = auth()->user(); + if ($user->roles[0]->name == 'Mahasiswa') { + return $query->where('mahasiswa_id', $user->id); + } + return $query; + }); } public static function getPages(): array @@ -67,4 +75,4 @@ public static function getPages(): array 'index' => Pages\ListPengumuman::route('/'), ]; } -} \ No newline at end of file +}