Esempio n. 1
0
 public function searchRegions($exclude = null)
 {
     $string = Input::get('query');
     $query = Region::where('is_structural', 0)->where('shortcut_id', null)->with('country', 'regionType')->whereTranslationLike('name', "%{$string}%")->orderByTranslation('sortas');
     if ($exclude) {
         if ($exclude = Region::find($exclude)) {
             $query->where('country_id', $exclude->country_id)->where($exclude->getLeftColumnName(), '<', $exclude->getLeft())->where($exclude->getRightColumnName(), '<', $exclude->getRight());
         } else {
             return $this->response->errorBadRequest();
         }
     }
     $results = $query->get();
     $transformer = new RegionTransformer();
     return $this->response->collection($results, $transformer);
 }
Esempio n. 2
0
 private function getRegionResults()
 {
     $query = Region::where('is_structural', 0)->where('shortcut_id', null)->with('country', 'regionType');
     $transformer = new RegionTransformer();
     return [$transformer, $query];
 }