<?php

namespace App\Repositories;

use App\Models\City;
use Illuminate\Database\Eloquent\Model;

class CityRepository extends BaseRepository
{
    public function __construct(City $model)
    {
        parent::__construct($model);
    }

    public function create(array $attributes): Model
    {
        return parent::create($attributes);
    }

    public function update(Model $model, array $attributes): bool
    {
        return parent::update($model, $attributes);
    }

    public function getActiveCities()
    {
        return $this->model->active()->orderBy('name->en')->get();
    }

    public function getCitiesByCountry(int $countryId)
    {
        return $this->model->where('country_id', $countryId)->active()->orderBy('name->en')->get();
    }
}
