CourseWork/app/Services/SubjectService.php

23 lines
516 B
PHP
Raw Permalink Normal View History

2024-06-22 23:59:16 +04:00
<?php
namespace App\Services;
use App\Models\Student;
use App\Models\Subject;
use Illuminate\Support\Facades\Auth;
class SubjectService
{
public function getSubjects()
{
if(Auth::user()->userable_type == Student::class) {
2024-06-23 17:02:18 +04:00
return Subject::whereIn('id', Auth::user()->userable->grade->subjects->pluck('id'))
2024-06-22 23:59:16 +04:00
->filter()
->paginate(5)
->withQueryString();
}
return Subject::filter()->paginate(5)->withQueryString();
}
}