/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->delete(); $user_id = DB::table('users')->select('id')->where('email', '*****@*****.**')->first()->id; $group_id = DB::table('groups')->select('id')->where('name', 'Administrator')->first()->id; UserGroup::create(array('user_id' => $user_id, 'group_id' => $group_id)); }
public function run() { DB::table('user_groups')->delete(); UserGroup::create(['id' => UserGroup::SUPER_USER, 'value' => 'Super User']); UserGroup::create(['id' => UserGroup::COMMUNITY_USER, 'value' => 'Community User']); UserGroup::create(['id' => UserGroup::CRM_USER, 'value' => 'Basic User']); }
/** * Remove user from a specified group * * @param $userId * @param $groupId * @return \Illuminate\Http\Response */ public function removeUserFromGroup($groupId, $userId) { $group = UserGroup::find($groupId); $group->users()->detach($userId); Flash::success(Lang::get('users_groups.update-success')); return redirect(action('UsersManagementController@index') . '#orgagroupsaccess'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $groups = ['0' => 'Select User Group'] + UserGroup::select('id', 'group_name')->orderBy('group_name')->lists('group_name', 'id')->toArray(); $user = User::with('group')->findOrFail($id); $agencies = Agency::orderBy('name')->lists('name', 'id'); $dentists = Dentist::orderBy('name')->lists('name', 'id'); $data = array('user' => $user, 'groups' => $groups, 'agencies' => $agencies, 'dentists' => $dentists, 'pageTitle' => 'ODRMS - User Management - Edit: ' . $user->name); return view('libraries.users.edit', $data); }
/** * Store a newly created User in storage. * * @return Response 200 * @return string message */ public function store() { $input = Input::all(); $group = new Group(); $group->groupName = $input['groupName']; $group->createdBy = Auth::id(); $group->save(); $user_group = new UserGroup(); $user_group->user_id = Auth::id(); $user_group->group_id = $group->id; $user_group->role = 1; $user_group->save(); $users = $input['users']; $emails = explode(',', $users); foreach ($emails as $email) { $user = User::where('email', $email)->first(); if (!empty($user)) { DB::table('users_groups')->insert(['user_id' => $user->id, 'group_id' => $group->id, 'role' => 2]); } } return Redirect::to('/classes'); }
/** * return json user */ public function getUsers($id) { if ($id == "pm") { $idus = UserGroup::distinct()->where("group_id", "=", 6)->orWhere("group_id", "=", 11)->groupBy('user_id')->get(array("user_id")); $user = array(); foreach ($idus as $key) { array_push($user, User::get(array("fullname", "id"))->find($key['user_id'])); } return json_encode($user); } else { $i = UserGroup::distinct()->where('group_id', '<>', 11)->groupBy('user_id')->get(); $u = array(); foreach ($i as $key) { array_push($u, User::get(array("fullname", "id"))->find($key['user_id'])); } return json_encode($u); } }
/** * Remove the specified resource from storage. * * @param int $id * @param OsjsService $service * @return \Illuminate\Http\Response */ public function destroy($id, OsjsService $service) { $group = UserGroup::findOrFail($id); $name = $this->organization->uuid . "-" . $group->name; if ($path = $service->deleteDirectory('group', $name)) { $group->delete(); Flash::success(Lang::get('groups.destroy-success')); } else { Flash::error(Lang::get('groups.destroy-failed')); } return redirect(action('UsersManagementController@index') . '#orgagroups'); }
public function getEditUserGroup($id) { $this->pageSetting(['menu_group_id' => 50, 'menu_id' => 1, 'title' => 'แก้ไขข้อมูลกลุ่มผู้ใช้ | MEA']); //if(isset($id)) abort(404); $user_group_data = UserGroup::where('USER_PRIVILEGE_ID', $id)->first(); $arr = $this->getMenuList($user_group_data->ACCESS_PERMISSIONS); return view('backend.pages.edit_user_group')->with(['menu_frontend_list' => $arr['frontend'], 'menu_backend_list' => $arr['backend'], 'user_group' => $user_group_data]); }
public function DELETE_deleteUser($id) { $user = User::find($id); if (!$user) { $msg = 'User not found.'; return redirect(route('user.list'))->with('STATUS_FAIL', $msg); } else { $name = $user->name; $user->delete(); $ug = UserGroup::where('user_id', $id); $ug->delete(); return redirect(route('user.list'))->with('STATUS_OK', 'User `' . $name . '` has been deleted.'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $group = UserGroup::findOrFail($id); if ($group->delete()) { flash()->success('Record delete.'); return redirect('admin/groups'); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(User $users, Request $request, UserGroup $user_groups, UserLocation $user_locations) { $user = array(); $user = $request->all(); if ($request->get('password') != null) { $user['password'] = Hash::make($request->get('password')); } else { unset($user['password']); } unset($user['_token']); unset($user['_method']); unset($user['photo']); unset($user['dob']); unset($user['group_id']); unset($user['retype_password']); $users->where('id', '=', $request->get('id'))->update($user); $locations = array(); $locations['location_id'] = Session::get('location_id'); $userId = $user['id']; $user_locations->where('user_id', $userId)->update($locations); $group = array(); $group['group_id'] = $request->get('group_id'); //$userId = $request->get('user_id'); $user_groups->where('user_id', $userId)->update($group); return Redirect::route('users.index'); }
public function DELETE_deleteGroup($id) { $group = Group::find($id); if (!$group) { $msg = 'Group not found.'; return redirect(route('group.assign'))->with('STATUS_FAIL', $msg); } else { $group_name = $group->name; $group->delete(); $ug = UserGroup::where('group_id', $id); $ug->delete(); return redirect(route('group.assign'))->with('STATUS_OK', 'Group `' . $group_name . '` has been deleted.'); } }