- Added CategoryController for handling category operations. - Created CategoryRequest for validation of category data. - Introduced CategoryService for business logic related to categories. - Implemented sluggable functionality in the Category model for automatic slug generation. - Developed UI components for category management, including a data table and dialogs for creating and editing categories. - Updated routes to include resourceful routes for categories.
32 lines
586 B
PHP
32 lines
586 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::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();
|
|
}
|
|
}
|