CourseWork/app/Services/SubjectService.php
2024-06-22 23:59:16 +04:00

25 lines
550 B
PHP

<?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) {
$student = Auth::user()->userable;
return Subject::whereIn('id', $student->grade->subjects->pluck('id'))
->filter()
->paginate(5)
->withQueryString();
}
return Subject::filter()->paginate(5)->withQueryString();
}
}