feat: add navigation badge for upcoming assignments and set badge color to danger
This commit is contained in:
parent
7602e1ad09
commit
a20ca4b0b3
@ -20,6 +20,36 @@ class AssignmentResource extends Resource
|
|||||||
{
|
{
|
||||||
protected static ?string $model = Assignment::class;
|
protected static ?string $model = Assignment::class;
|
||||||
|
|
||||||
|
public static function getNavigationBadge(): ?string
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
if (! $user?->student) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$student = $user->student;
|
||||||
|
$now = now();
|
||||||
|
|
||||||
|
$count = static::getEloquentQuery()
|
||||||
|
->where('due_date', '>', $now)
|
||||||
|
->where(function (Builder $query) use ($student) {
|
||||||
|
$query->whereHas('students', fn ($q) => $q->whereKey($student->id))
|
||||||
|
->orWhereHas('studyGroups', fn ($q) => $q->where('leader_id', $student->id)->orWhereHas('students', fn ($sq) => $sq->whereKey($student->id)));
|
||||||
|
})
|
||||||
|
->whereDoesntHave('assignmentSubmissions', function (Builder $query) use ($student) {
|
||||||
|
$query->where('student_id', $student->id)
|
||||||
|
->orWhereHas('studyGroup', fn ($sq) => $sq->where('leader_id', $student->id)->orWhereHas('students', fn ($ssq) => $ssq->whereKey($student->id)));
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
|
||||||
|
return $count > 0 ? (string) $count : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationBadgeColor(): ?string
|
||||||
|
{
|
||||||
|
return 'danger';
|
||||||
|
}
|
||||||
|
|
||||||
protected static string|UnitEnum|null $navigationGroup = 'Pembelajaran';
|
protected static string|UnitEnum|null $navigationGroup = 'Pembelajaran';
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-clipboard-document-list';
|
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-clipboard-document-list';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user