update the new school year model
This commit is contained in:
@@ -7,10 +7,21 @@ use App\Models\ClassProgressReport;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\TeacherClass;
|
||||
use App\Models\User;
|
||||
use App\Services\SchoolYears\SchoolYearContextService;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class ClassProgressQueryService
|
||||
{
|
||||
private SchoolYearContextService $schoolYears;
|
||||
|
||||
public function __construct($schoolYears = null)
|
||||
{
|
||||
$this->schoolYears = $schoolYears instanceof SchoolYearContextService
|
||||
? $schoolYears
|
||||
: app(SchoolYearContextService::class);
|
||||
}
|
||||
|
||||
public function listReports(User $user, array $filters): LengthAwarePaginator
|
||||
{
|
||||
$query = ClassProgressReport::query()
|
||||
@@ -51,6 +62,14 @@ class ClassProgressQueryService
|
||||
$query->where('status', (string) $filters['status']);
|
||||
}
|
||||
|
||||
if (!empty($filters['school_year']) && Schema::hasColumn('class_progress_reports', 'school_year')) {
|
||||
$query->where('school_year', (string) $filters['school_year']);
|
||||
}
|
||||
|
||||
if (!empty($filters['semester']) && Schema::hasColumn('class_progress_reports', 'semester')) {
|
||||
$query->where('semester', (string) $filters['semester']);
|
||||
}
|
||||
|
||||
if (!empty($filters['week_start'])) {
|
||||
$query->whereDate('week_start', '>=', $filters['week_start']);
|
||||
}
|
||||
@@ -132,6 +151,11 @@ class ClassProgressQueryService
|
||||
return TeacherClass::getClassAssignmentsByUserId($user->id, $schoolYear, $semester);
|
||||
}
|
||||
|
||||
public function meta(?string $schoolYear = null, ?string $semester = null): array
|
||||
{
|
||||
return $this->schoolYears->options($schoolYear, $semester);
|
||||
}
|
||||
|
||||
private function statusLabel(?string $status): string
|
||||
{
|
||||
$options = (array) config('progress.status_options', []);
|
||||
|
||||
Reference in New Issue
Block a user