fix: adding condition at pengumuman

This commit is contained in:
Fardan Nozami Ajitama 2025-05-01 11:26:41 +07:00
parent badb4572b6
commit fadbabde01
1 changed files with 14 additions and 6 deletions

View File

@ -10,6 +10,7 @@
use Filament\Tables\Table; use Filament\Tables\Table;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ViewColumn; use Filament\Tables\Columns\ViewColumn;
use Illuminate\Database\Eloquent\Builder; // Add this line
class PengumumanResource extends Resource class PengumumanResource extends Resource
{ {
@ -20,7 +21,7 @@ class PengumumanResource extends Resource
protected static ?string $navigationLabel = 'Pengumuman'; protected static ?string $navigationLabel = 'Pengumuman';
protected static ?int $navigationSort = 3; protected static ?int $navigationSort = 3;
protected static ?string $slug = 'pengumuman'; protected static ?string $slug = 'pengumuman';
protected static ?string $modelLabel = 'Pengumuman'; protected static ?string $modelLabel = 'Pengumuman';
protected static ?string $pluralModelLabel = 'Pengumuman'; protected static ?string $pluralModelLabel = 'Pengumuman';
protected static ?string $breadcrumb = 'Pengumuman'; protected static ?string $breadcrumb = 'Pengumuman';
@ -33,7 +34,7 @@ public static function table(Table $table): Table
->label('Nama Mahasiswa') ->label('Nama Mahasiswa')
->searchable() ->searchable()
->sortable(), ->sortable(),
TextColumn::make('status') TextColumn::make('status')
->label('Status Berkas') ->label('Status Berkas')
->badge() ->badge()
@ -43,7 +44,7 @@ public static function table(Table $table): Table
'belum_validasi' => 'warning', 'belum_validasi' => 'warning',
default => 'gray', default => 'gray',
}), }),
TextColumn::make('hasil') TextColumn::make('hasil')
->label('Hasil Seleksi') ->label('Hasil Seleksi')
->badge() ->badge()
@ -53,12 +54,19 @@ public static function table(Table $table): Table
'Tidak Layak' => 'danger', 'Tidak Layak' => 'danger',
default => 'gray', default => 'gray',
}), }),
ViewColumn::make('keterangan') ViewColumn::make('keterangan')
->label('Keterangan') ->label('Keterangan')
->view('filament.tables.columns.keterangan-pengumuman'), ->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 public static function getPages(): array
@ -67,4 +75,4 @@ public static function getPages(): array
'index' => Pages\ListPengumuman::route('/'), 'index' => Pages\ListPengumuman::route('/'),
]; ];
} }
} }