<?

namespace Shop\Controllers;

use Core\Form\ControlBuilder;
/**
 * Description of City
 *
 * @author Admin
 */
class City extends \Core\BaseController{
    //put your code here
    
    protected $cityRepo;
    
    protected $builder;
            
    function __construct(\Shop\Repositories\City $cityRepo,ControlBuilder $cBuilder) {
        $this->cityRepo = $cityRepo;
        $this->builder = $cBuilder;
    }
            
    function index(){
        
        $dropdown = $this->cityRepo->getDropdownListByregion(input_get("region"));
                
        $data []= [
                "id"    =>  null,
                "value" =>  "- не выбранно -"
            ];
        foreach($dropdown as $key=>$value){
            
            $data[]=[
                "id"    =>  $key,
                "value" =>  $value
            ];
        }
        
        return new \Symfony\Component\HttpFoundation\JsonResponse($data);
    }
    
}
