Files
laravel-backend/app/Services/BranchService.php
Joris Slagter df155bb13d
Some checks failed
continuous-integration/drone/push Build is failing
Initial Laravel API import
- 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
2025-12-02 17:40:21 +01:00

53 lines
1.1 KiB
PHP

<?php
namespace App\Services;
use App\Repositories\Branch;
class BranchService
{
private $branchRepository;
public function __construct(Branch $branchRepository)
{
$this->branchRepository = $branchRepository;
}
public function save(array $data)
{
if (isset($data['id'])) {
$branch = $this->branchRepository->findOrFail($data['id']);
$branch->update($data);
} else {
$branch = $this->branchRepository->create($data);
}
return $branch;
}
public function delete($id)
{
$branch = $this->branchRepository->findOrFail($id);
$branch->delete();
}
public function get($id)
{
return $this->branchRepository->findOrFail($id);
}
public function getAll()
{
return $this->branchRepository->all();
}
public function with(array $children)
{
return $this->branchRepository->with($children)->get();
}
public function getOneWith($id, array $children)
{
return $this->branchRepository->with($children)->findOrFail($id);
}
}