25 lines
550 B
PHP
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();
|
||
|
}
|
||
|
}
|