Merge pull request #1 from fardannozami/master

fix: dashboard and pengumuman
This commit is contained in:
najwasz 2025-05-01 11:32:05 +07:00 committed by GitHub
commit 00cd727ac4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 7 deletions

View File

@ -2,7 +2,23 @@
namespace App\Filament\Pages;
use Filament\Facades\Filament;
use Illuminate\Support\Facades\Auth;
class Dashboard extends \Filament\Pages\Dashboard
{
protected static ?string $title = 'Beranda';
}
public function getWidgets(): array
{
/** @var User $user */
$user = Auth::user();
if ($user->hasRole('Mahasiswa')) { {
return [
\App\Filament\Widgets\CustomAccountWidget::class,
];
}
}
return Filament::getWidgets();
}
}

View File

@ -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('/'),
];
}
}
}