CourseWork/app/Services/LessonService.php

40 lines
716 B
PHP
Raw Normal View History

2024-05-08 12:59:29 +04:00
<?php
namespace App\Services;
2024-05-08 16:55:32 +04:00
use App\Models\Grade;
2024-05-08 12:59:29 +04:00
use App\Models\Lesson;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class LessonService implements ServiceInterface
{
2024-05-08 16:55:32 +04:00
public function getAll(?Grade $grade = null): Collection
2024-05-08 12:59:29 +04:00
{
2024-05-08 16:55:32 +04:00
return $grade->lessons;
}
public function getGrades(): Collection
{
return Grade::all();
2024-05-08 12:59:29 +04:00
}
public function create(array $data): Lesson
{
return Lesson::create($data);
}
public function update(Model $model, array $data): Lesson
{
$model->update($data);
return $model;
}
public function delete($model): void
{
$model->delete();
}
}