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.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Repositories\Synonym;
|
|
|
|
class SynonymService
|
|
{
|
|
private $synonymRepository;
|
|
|
|
public function __construct(Synonym $synonymRepository)
|
|
{
|
|
$this->synonymRepository = $synonymRepository;
|
|
}
|
|
|
|
public function save(array $data)
|
|
{
|
|
if (isset($data['id'])) {
|
|
$synonym = $this->synonymRepository->findOrFail($data['id']);
|
|
$synonym->update($data);
|
|
} else {
|
|
$synonym = $this->synonymRepository->create($data);
|
|
}
|
|
|
|
return $synonym;
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
$synonym = $this->synonymRepository->findOrFail($id);
|
|
$synonym->delete();
|
|
}
|
|
|
|
public function get($id)
|
|
{
|
|
return $this->synonymRepository->findOrFail($id);
|
|
}
|
|
|
|
public function getAll()
|
|
{
|
|
return $this->synonymRepository->all();
|
|
}
|
|
|
|
public function with(array $children)
|
|
{
|
|
return $this->synonymRepository->with($children)->get();
|
|
}
|
|
|
|
public function getOneWith($id, array $children)
|
|
{
|
|
return $this->synonymRepository->with($children)->findOrFail($id);
|
|
}
|
|
} |