Some checks failed
continuous-integration/drone/push Build is failing
- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Repositories\ChecklistCategory;
|
|
|
|
class ChecklistCategoryService
|
|
{
|
|
private $checklistCategoryRepository;
|
|
|
|
public function __construct(ChecklistCategory $checklistCategoryRepository)
|
|
{
|
|
$this->checklistCategoryRepository = $checklistCategoryRepository;
|
|
}
|
|
|
|
public function save(array $data)
|
|
{
|
|
if (isset($data['id'])) {
|
|
$checklistCategory = $this->checklistCategoryRepository->findOrFail($data['id']);
|
|
$checklistCategory->update($data);
|
|
} else {
|
|
$checklistCategory = $this->checklistCategoryRepository->create($data);
|
|
}
|
|
|
|
return $checklistCategory;
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
$checklistCategory = $this->checklistCategoryRepository->findOrFail($id);
|
|
$checklistCategory->delete();
|
|
}
|
|
|
|
public function get($id)
|
|
{
|
|
return $this->checklistCategoryRepository->findOrFail($id);
|
|
}
|
|
|
|
public function getAll()
|
|
{
|
|
return $this->checklistCategoryRepository->all();
|
|
}
|
|
|
|
public function with(array $children)
|
|
{
|
|
return $this->checklistCategoryRepository->with($children)->get();
|
|
}
|
|
|
|
public function getOneWith($id, array $children)
|
|
{
|
|
return $this->checklistCategoryRepository->with($children)->findOrFail($id);
|
|
}
|
|
} |