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
 public static function getSelect($id)
 {
     if ($id) {
         $transformer = new RegionTransformer();
         $selected = Region::find($id);
         return json_encode($transformer->transform($selected));
     }
     return '';
 }