<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\CommonGetCitiesRequest;
use App\Models\City;
use Illuminate\Http\Request;

class CommonController extends Controller
{
    /**
     * Ülkeye göre şehirleri getir
     *
     * @param  Request  $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getCities(CommonGetCitiesRequest $request)
    {

        $cities = City::where('country_id', $request->country_id)
            ->orderBy('name')
            ->get(['id', 'name']);

        return response()->json([
            'success' => true,
            'data' => $cities,
        ]);
    }
}
