CourseWork/app/Services/SubjectService.php
2024-05-06 17:47:25 +04:00

34 lines
646 B
PHP

<?php
namespace App\Services;
use App\Models\Subject;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\LengthAwarePaginator;
class SubjectService implements ServiceInterface
{
public function getAll(): LengthAwarePaginator
{
return Subject::filter()->paginate(5)->withQueryString();
}
public function create(array $data): Subject
{
return Subject::create($data);
}
public function update(Model $model, array $data): Subject
{
$model->update($data);
return $model;
}
public function delete(Model $model): void
{
$model->delete();
}
}