24 lines
491 B
PHP
24 lines
491 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Services;
|
||
|
|
||
|
use App\Models\Grade;
|
||
|
use App\Models\Teacher;
|
||
|
use Illuminate\Support\Facades\Auth;
|
||
|
|
||
|
class LessonService
|
||
|
{
|
||
|
public function getLessons(Grade $grade)
|
||
|
{
|
||
|
if (Auth::user()->userable_type == Teacher::class) {
|
||
|
return $grade
|
||
|
->lessons()
|
||
|
->where('teacher_id', Auth::user()->userable_id)
|
||
|
->filter()
|
||
|
->get();
|
||
|
}
|
||
|
|
||
|
return $grade->lessons()->filter()->get();
|
||
|
}
|
||
|
}
|