/** * Get list of organisations where user is not in */ public function scopeSelectNotInOrganisation($query, $user, $title = "Select") { $ids = OrganisationUser::where('user_id', $user)->lists('organisation_id'); $selectVals[''] = $title; if ($ids) { $selectVals += $this->whereNotIn('id', $ids)->orderBy('name', 'asc')->lists('name', 'id'); } else { $selectVals += $this->orderBy('name', 'asc')->lists('name', 'id'); } return $selectVals; }
/** * Delete user */ public function delete_user($organisation, $id) { if (OrganisationUser::where('organisation_id', $organisation)->where('user_id', $id)->delete()) { return Redirect::route('organisation_modify', $organisation)->with('mSuccess', 'Cet utilisateur a bien été retiré de cette société'); } else { return Redirect::route('organisation_modify', $organisation)->with('mError', 'Impossible de retirer cet utilisateur'); } }
/** * Get list of users in organisations */ public function scopeSelectInOrganisation($query, $organisation, $title = "Select") { $ids = OrganisationUser::where('organisation_id', $organisation)->lists('user_id'); $selectVals[''] = $title; if ($ids) { $selectVals += $this->whereIn('id', $ids)->get()->lists('fullname', 'id'); } return $selectVals; }