CourseWork/app/Services/LessonService.php

24 lines
491 B
PHP
Raw Permalink Normal View History

2024-06-24 00:51:05 +04:00
<?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();
}
}