コード例 #1
0
 /**
  * @param string $order_by
  * @param string $sort
  * @return mixed
  */
 public function getAllOrganizations($order_by = 'id', $sort = 'asc')
 {
     return Organization::orderBy($order_by, $sort)->get();
 }
コード例 #2
0
 /**
  * @param string $order_by
  * @param string $sort
  * @return mixed
  */
 public function getAllOrganizations($order_by = 'id', $sort = 'asc', $with = [])
 {
     if (!access()->user()->can('manage_organization')) {
         $organizations = Organization::where('id', access()->user()->organization->id)->orderBy($order_by, $sort);
     } else {
         $organizations = Organization::orderBy($order_by, $sort);
     }
     if (!empty($with)) {
         return $organizations->with($with)->get();
     } else {
         return $organizations->get();
     }
 }