CourseWork/app/Services/SubjectService.php
2024-06-23 17:02:18 +04:00

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