/** * @param string $order_by * @param string $sort * @return mixed */ public function getAllOrganizations($order_by = 'id', $sort = 'asc') { return Organization::orderBy($order_by, $sort)->get(); }
/** * @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(); } }