CourseWork/app/Services/SubjectService.php

33 lines
645 B
PHP
Raw Normal View History

2024-04-23 14:52:49 +04:00
<?php
namespace App\Services;
use App\Models\Subject;
2024-05-06 17:47:25 +04:00
use Illuminate\Database\Eloquent\Model;
2024-04-23 14:52:49 +04:00
use Illuminate\Pagination\LengthAwarePaginator;
class SubjectService implements ServiceInterface
{
public function getAll(): LengthAwarePaginator
{
2024-05-06 17:47:25 +04:00
return Subject::filter()->paginate(5)->withQueryString();
2024-04-23 14:52:49 +04:00
}
public function create(array $data): Subject
{
return Subject::create($data);
}
2024-05-06 17:47:25 +04:00
public function update(Model $model, array $data): Subject
2024-04-23 14:52:49 +04:00
{
$model->update($data);
return $model;
}
2024-05-06 17:47:25 +04:00
public function delete(Model $model): void
2024-04-23 14:52:49 +04:00
{
$model->delete();
}
}