| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Services;
- use App\Repositories\CountryRepositoryInterface;
- use App\DTO\CountryDTO;
- use Illuminate\Database\Eloquent\Collection;
- use App\Models\Country;
- class CountryService
- {
- public function __construct(
- protected CountryRepositoryInterface $repository
- ){
- }
- public function getAllItems(): Collection
- {
- return $this->repository->all();
- }
- public function getItem(int $id): ?Country
- {
- return $this->repository->find($id);
- }
- public function createItem(CountryDTO $dto): Country
- {
- return $this->repository->create($dto);
- }
- public function updateItem(CountryDTO $dto, int $id): Country
- {
- return $this->repository->update($id, $dto, request()->keys());
- }
- public function deleteItem(int $id): bool
- {
- return $this->repository->delete($id);
- }
- }
|