Get Administrative areas collection of a country given

@param int $country_id
@param Illuminate\Http\Request $request
@return mixed Jnaxo\CountryCodes\AdministrativeArea collection
193171
public function administrativeAreas($country_id, Request $request = null)
    {
        $query = AdministrativeArea::where('country_id', $country_id)
            ->with('country');

        if ($request) {
            $resource = new Collection($query, 'administrative_area', $request);
            return $this->respondWithCollection($resource);
        }
        return $query->get();
    }
274757
public function getRouteList($regionId, $q, $routeType = null, $page = 1, $pageSize = 20, $fields = null)
    {
        $params = array(
            'region_id' => (int)$regionId,
            'q' => (string)$q,
            'page' => (int)$page,
            'pageSize' => (int)$pageSize
        );
        if ($routeType) {
            $params['route_type'] = (string)$routeType;
        }
        if ($fields) {
            $params['fields'] = (string)$fields;
        }
        return $this->getInternalList(
            'transport/route/search',
            'Route',
            $params
        );
    }
988831
public function all($countryId, array $params = array())
    {
        $endpoint = '/admin/countries/'.$countryId.'/provinces.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createCollection(Province::class, $response['provinces']);
    }
763772
public function getAction(Request $request, $attributeId, $attributeValueId)
    {
        $locale = $this->getLocale($request);
        try {
            $this->getAttributeManager()->findByIdAndLocale($attributeId, $locale);
        } catch (AttributeNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);

            return $this->handleView($view);
        }

        try {
            $attributeValue = $this->getManager()->findByIdAndLocale($attributeValueId, $locale);
            $view = $this->view($attributeValue, 200);
        } catch (AttributeValueNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);
        }

        return $this->handleView($view);
    }
568472
protected static function getWorldContries($only_names = false) : Collection
    {
        $file = __DIR__ . "/../Assets/topojson/world-countries.json";

        return Collection::make(
            json_decode(file_get_contents($file), true)['objects']['countries1']['geometries']
        )->map(function ($country) use ($only_names) {
            if ($only_names) {
                return $country['properties']['name'];
            }
            return $country['properties'];
        });
    }
467964
public function findByCountryAndModule(Country $country, Module $module, State $state = null)
    {
        $response = null;

        $countryInAreaList = CountryAreaQuery::findByCountryAndState($country, $state);

        /** @var CountryArea $countryInArea */
        foreach ($countryInAreaList as $countryInArea) {
            $response = self::create()->filterByAreaId($countryInArea->getAreaId())
                ->filterByModule($module)
                ->findOne()
            ;

            if ($response !== null) {
                break;
            }
        }

        return $response;
    }
329280
public function getTemplateAction(Request $request, $id)
    {
        $version = $request->query->get('_version');

        /** @var TemplateBlockProvider $templateBlockProvider */
        $templateBlockProvider = $this->get('opifer.content.template_block_provider');
        $template = $templateBlockProvider->getBlockOwner($id);

        /** @var Environment $environment */
        $environment = $this->get('opifer.content.block_environment');
        $environment->setObject($template);

        if (null !== $version && $this->isGranted('ROLE_ADMIN')) {
            $environment->setDraft(true);
        }

        $environment->load();

        $blocks = $environment->getRootBlocks();

        $context = SerializationContext::create();
        $context->setGroups(['Default', 'tree', 'detail']);

        $contentItem = [
            'id' => $template->getId(),
            'name' => $template->getName(),
            'display_name' => $template->getDisplayName(),
            'blocks' => $blocks,
        ];

        $json = $this->get('jms_serializer')->serialize($contentItem, 'json', $context);

        return new JsonResponse(json_decode($json, true));
    }
1200490
public function getRouteCollectionForRequest(Request $request)
    {
        $collection = new RouteCollection();

        // Fetch pages IDs by request path.
        $qb = $this->pageRepository->createQueryBuilder('p');
        $qb
            ->select('p.id')
            ->join('p.translations', 't')
            ->andWhere($qb->expr()->eq('p.static', 0))
            ->andWhere($qb->expr()->eq('t.path', $qb->expr()->literal(rawurldecode($request->getPathInfo()))))
        ;
        $results = $qb
            ->getQuery()
            ->getArrayResult()
        ;
        if (empty($results)) {
            return $collection;
        }

        $ids = array_unique(array_map(function($row) {
            return $row['id'];
        }, $results));

        // Fetch pages by IDs
        $qb = $this->pageRepository->createQueryBuilder('p');
        $results = $qb
            ->select('p.route, p.controller, t.path, t.locale')
            ->join('p.translations', 't')
            ->andWhere($qb->expr()->eq('p.static', 0))
            ->andWhere($qb->expr()->in('p.id', $ids))
            ->getQuery()
            ->getArrayResult()
        ;

        $routes =  $this->transformResultsToRoutes($results);

        // Build collection
        foreach ($routes as $name => $route) {
            $collection->add($name, $route);
        }

        return $collection;
    }
466579
public function getAction(Request $request, $id)
    {
        if (null !== $request->get('fields')) {
            return $this->getContent($request, $id);
        }

        return $this->getSingleNode($request, $id);
    }
571157
public function getCollectionAction(Request $request, $start, $count, KeyWord $parent = null)
    {
        $results = [];

        $term = $request->query->get('term', null);
        $uids = array_filter(explode(',', $request->query->get('uids')));
        $preserveOrder = (boolean) $request->query->get('preserve_order');

        if (null !== $term) {
            $results = $this->getKeywordRepository()->getLikeKeyWords($term);
        } elseif (!empty($uids)) {
            $results = $this->getKeywordRepository()->findBy(['_uid' => $uids]);

            if ($preserveOrder === true) {
                $results = $this->sortByUids($uids, $results);
            }
        } else {
            $orderInfos = [
                'field' => '_leftnode',
                'dir' => 'asc',
            ];
            $results = $this->getKeywordRepository()->getKeyWords($parent, $orderInfos, array('start' => $start, 'limit' => $count));
        }

        $total = count($results);
        if ($results instanceof Paginator) {
            $results = iterator_to_array($results->getIterator());
        }

        return $this->addRangeToContent($this->createJsonResponse($results), $total, $start, count($results));
    }
833655
public function treeAction(Request $request = null)
    {
        $this->admin->checkAccess('tree');

        $sites = $this->get('sonata.page.manager.site')->findBy(array());
        $pageManager = $this->get('sonata.page.manager.page');

        $currentSite = null;
        $siteId = $request->get('site');
        foreach ($sites as $site) {
            if ($siteId && $site->getId() === $siteId) {
                $currentSite = $site;
            } elseif (!$siteId && $site->getIsDefault()) {
                $currentSite = $site;
            }
        }
        if (!$currentSite && count($sites) === 1) {
            $currentSite = $sites[0];
        }

        $showAllPages = $this->get('security.context')->isGranted('ROLE_SUPER_ADMIN');

        if ($currentSite) {
            $pages = $pageManager->loadPages($currentSite, $showAllPages);
        } else {
            $pages = array();
        }

        $datagrid = $this->admin->getDatagrid();
        $formView = $datagrid->getForm()->createView();

        $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());

        return $this->render($this->admin->getTemplate('tree'), array(
            'action' => 'tree',
            'sites' => $sites,
            'currentSite' => $currentSite,
            'pages' => $pages,
            'form' => $formView,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
        ));
    }
908874
public function getAction($id, Request $request)
    {
        $includes = explode(',', $request->get('include'));
        $accountManager = $this->getAccountManager();
        $locale = $this->getUser()->getLocale();

        try {
            $view = $this->responseGetById(
                $id,
                function($id) use ($includes, $accountManager, $locale) {
                    return $accountManager->getByIdAndInclude($id, $locale, $includes);
                }
            );

            $context = new Context();
            $context->setGroups(self::$accountSerializationGroups);
            $view->setContext($context);
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        }

        return $this->handleView($view);
    }
395306
public function store(Request $request)
    {
        $rules = [
            "address" => "required|max:256",
            "country" => "required",
            "label" => "required|max:50",
            "municipality" => "required|max:128",
            "postcode" => 'required|regex:/^[0-9]{5}(-\d{4})?$/',
            "stateProvince" => "required",
        ];
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate($this->addPolymorphicRules($rules, 'addressable', $request->addressableType));
        $address = new Address();
        $address->addressable_id = $request->addressableId;
        $address->addressable_type = $request->addressableType;
        $address->label = $request->label;
        $address->address = $request->address;
        $address->municipality = $request->municipality;
        $address->state_province = $request->stateProvince;
        $address->postcode = $request->postcode;
        $address->country = $request->country;
        $this->authorize('manage', $address);
        $address->save();
        return fractal($address, new AddressTransformer())
            ->withResourceName('address')
            ->respond();
    }
1325125
public function postVerify($area, Request $request)
    {
        $area = app(AreaManager::class)->getById($area);
        return $this->processor->verifyCredentials($this, $area, $request->input());
    }
1343088
public function actionJscountry($search = NULL,$id = NULL)
  {
    Yii::$app->response->format = Response::FORMAT_JSON;
    $clean['more'] = false;

    $query = new Query;
    if(!is_Null($search))
    {
      $mainQuery = $query->select('id, iso3 AS text')
        ->from('{{%net_frenzel_country}}')
        ->where('UPPER(iso3) LIKE "%'.strtoupper($search).'%"');

      $command = $mainQuery->createCommand();
      $rows = $command->queryAll();
      $clean['results'] = array_values($rows);
    }
    else
    {     
      if(!is_null($id))
      {
        $clean['results'] = ['id'=> $id,'text' => Country::findOne($id)->iso3];
      }else
      {
        $clean['results'] = ['id'=> 0,'text' => 'None found'];
      }
    }
    return $clean;
  }
1352174
public function manageGlobalAction(Request $request)
    {
        $securitySettings = $this->container->getParameter('settings_manager.security');

        if (!empty($securitySettings['manage_global_settings_role']) &&
            !$this->getAuthorizationChecker()->isGranted($securitySettings['manage_global_settings_role'])
        ) {
            throw new AccessDeniedException(
                $this->container->get('translator')->trans(
                    'not_allowed_to_edit_global_settings',
                    array(),
                    'settings'
                )
            );
        }

        return $this->manage($request);
    }
2485
protected function getListCountry()
    {
        $conditions = $this->query_filter;
        $conditions['limit'] = $this->data_limit;

        return (array) $this->country->getList($conditions);
    }