Example #1
0
 /**
  * Mendapatkan Semua Locations
  *
  * @return mixed
  */
 public function all()
 {
     $page = \Input::get('page');
     $limit = \Input::get('limit', 1);
     $start = \Input::get('start', 0);
     if (Input::has('cbreq')) {
         $data = $this->locations;
         if (Input::has('level')) {
             $level = Input::get('level');
             $data = $data->where('level', $level);
         }
         if (Input::has('parent_id')) {
             $parentId = Input::get('parent_id');
             $data = $data->whereParentId($parentId);
         }
         $total = $data->count();
         $response = $data->skip($start)->take($limit)->get()->toArray();
         return Response::json(array('results' => $response, 'success' => true, 'total' => $total));
     }
     /**
      * Request dari Grid
      */
     $locations = $this->locations->orderBy('created_at', 'DESC');
     if (Input::has('type')) {
         $type = Input::get('type');
         if (Input::has('parentId')) {
             $parentId = Input::get('parentId');
             $locations = $this->locations->findByTypeAndParent($type, $parentId, Input::all());
             return $this->response($locations['results'], $locations['total']);
         }
         $locations = $this->locations->findByType($type, Input::all());
         return $this->response($locations['results'], $locations['total']);
     }
     $total = $locations->count();
     $locations = $locations->skip($start)->take($limit)->get()->toArray();
     return $this->response($locations, $total);
 }