32 lines
608 B
PHP
32 lines
608 B
PHP
<?php
|
|
|
|
namespace App\Services\Admin\Master;
|
|
|
|
use App\Models\Category;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
class CategoryService
|
|
{
|
|
public function getAll(): Collection
|
|
{
|
|
return Category::select('id', 'name')->latest()->get();
|
|
}
|
|
|
|
public function create(array $data): Category
|
|
{
|
|
return Category::create($data);
|
|
}
|
|
|
|
public function update(Category $category, array $data): Category
|
|
{
|
|
$category->update($data);
|
|
|
|
return $category;
|
|
}
|
|
|
|
public function delete(Category $category): bool
|
|
{
|
|
return $category->delete();
|
|
}
|
|
}
|