CourseWork/app/Services/LessonService.php
2024-05-13 14:23:21 +04:00

40 lines
735 B
PHP

<?php
namespace App\Services;
use App\Models\Grade;
use App\Models\Lesson;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class LessonService implements ServiceInterface
{
public function getAll(?Grade $grade = null): Collection
{
return $grade->lessons()->filter()->get();
}
public function getGrades(): Collection
{
return Grade::all();
}
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();
}
}