<?php

namespace Modules\City\Services;

use Illuminate\Http\Request;
use Modules\City\Interfaces\CityRepositoryInterface;
use Modules\City\Models\City;

class CityService
{
    private CityRepositoryInterface $cityRepository ;

    public function __construct(CityRepositoryInterface $cityRepository)
    {
        $this->cityRepository = $cityRepository;
    }

    public function get(Request $request)
    {
        $countries = $this->cityRepository->get($request);
        return $countries;
    }
    public function getItem(City $city)
    {
        $city = $this->cityRepository->getItem($city);
        return $city;
    }
    public function save(Request $request, ?City $city): City
    {
        $city = $this->cityRepository->save($request,$city);
        return $city;
    }
    public function destroy(Request $request, int $id): array
    {
        $response = $this->cityRepository->destroy($request,$id);
        return $response;
    }
    public function destroyAll(Request $request): array
    {
        $response = $this->cityRepository->destroyAll($request);
        return $response;
    }
    public function restore(Request $request, int $id): array
    {
        $response = $this->cityRepository->restore($request,$id);
        return $response;
    }
    public function restoreAll(Request $request): array
    {
        $response = $this->cityRepository->restoreAll($request);
        return $response;
    }
    public function getRegions(City $city)
    {
        $request = request();
        $request->merge(['region_id'=>$city->region_id]);
        $cities = $this->get($request);
        return $cities;
    }
}
