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
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Repositories\Accreditation;
|
|
|
|
class AccreditationService
|
|
{
|
|
private $accreditationRepository;
|
|
|
|
public function __construct(Accreditation $accreditationRepository)
|
|
{
|
|
$this->accreditationRepository = $accreditationRepository;
|
|
}
|
|
|
|
public function save(array $data)
|
|
{
|
|
if (isset($data['id'])) {
|
|
$accreditation = $this->accreditationRepository->findOrFail($data['id']);
|
|
$accreditation->update($data);
|
|
} else {
|
|
$accreditation = $this->accreditationRepository->create($data);
|
|
}
|
|
|
|
return $accreditation;
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
$accreditation = $this->accreditationRepository->findOrFail($id);
|
|
$accreditation->delete();
|
|
}
|
|
|
|
public function get($id)
|
|
{
|
|
return $this->accreditationRepository->findOrFail($id);
|
|
}
|
|
|
|
public function getAll()
|
|
{
|
|
return $this->accreditationRepository->all();
|
|
}
|
|
|
|
public function with(array $children)
|
|
{
|
|
return $this->accreditationRepository->with($children)->get();
|
|
}
|
|
|
|
public function getOneWith($id, array $children)
|
|
{
|
|
return $this->accreditationRepository->with($children)->findOrFail($id);
|
|
}
|
|
}
|