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