<?

namespace Shop\Controllers;

use Core\Form\ControlBuilder;
/**
 * Description of Region
 *
 * @author Admin
 */
class Region extends \Core\BaseController
{

    protected $regionRepo;
    protected $builder;

    function __construct(\Shop\Repositories\Region $repo, ControlBuilder $cBuilder)
    {
        $this->regionRepo = $repo;
        $this->builder  = $cBuilder;
    }

    function index()
    {

        $dropdown = $this->regionRepo->getDropdownListByCountry(input_get("country"));

        $data [] = [
            "id"    => null,
            "value" => "- не выбранно -"
        ];
        foreach ($dropdown as $key => $value) {

            $data[] = [
                "id"    => $key,
                "value" => $value
            ];
        }

        return new \Symfony\Component\HttpFoundation\JsonResponse($data);
    }

}