芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/rentandbuyrealty.com/rentandbuyrealty.com/app/Http/Controllers/UserController.php
email)->get()->count()) { return redirect()->back()->with('error', 'Email already Registered please try using another email '); } if (!has_permissions('create', 'users_accounts')) { return redirect()->back()->with('error', PERMISSION_ERROR_MSG); } else { User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => Hash::make($request->Password), 'permissions' => isset($request->permissions) ? json_encode($request->permissions) : '', 'type' => 1, ]); return redirect()->back()->with('success', 'User Insert Successfully'); } } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { } public function edit($id) { $user_data = User::find($id); return $user_data; } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { if (!has_permissions('update', 'users_accounts')) { return redirect()->back()->with('error', PERMISSION_ERROR_MSG); } else { $id = $request->edit_id; $update = User::find($id); $update->name = $request->name; $update->email = $request->email; $update->permissions = isset($request->Editpermissions) ? json_encode($request->Editpermissions) : ''; $update->status = $request->status; $update->save(); return redirect()->back()->with('success', 'User Update Successfully'); } } public function userList(Request $request) { $offset = $request->input('offset', 0); $limit = $request->input('limit', 10); $sort = $request->input('sort', 'sequence'); $order = $request->input('order', 'ASC'); $sql = User::orderBy($sort, $order); if (isset($_GET['search']) && !empty($_GET['search'])) { $search = $_GET['search']; $sql->where('id', 'LIKE', "%$search%")->orwhere('email', 'LIKE', "%$search%")->orwhere('name', 'LIKE', "%$search%"); } $total = $sql->count(); if (isset($_GET['limit'])) { $sql->skip($offset)->take($limit); } $res = $sql->where('type', '=', '1')->get(); $bulkData = array(); $bulkData['total'] = $total; $rows = array(); $tempRow = array(); $count = 1; foreach ($res as $row) { $tempRow = $row->toArray(); $permission = ($row->permissions != '') ? base64_encode($row->permissions) : ''; $operate = '
'; $operate .= '
'; $tempRow['permissions'] = json_decode($row->permissions); $tempRow['operate'] = $operate; $rows[] = $tempRow; $count++; } $bulkData['rows'] = $rows; return response()->json($bulkData); } public function resetpassword(Request $request) { if (!has_permissions('update', 'users_accounts')) { return redirect()->back()->with('error', PERMISSION_ERROR_MSG); } else { $id = $request->pass_id; User::where('id', $id)->update(['password' => Hash::make($request->confPassword)]); return redirect()->back()->with('success', 'Password Reset Successfully'); } } public function updateFCMID(Request $request) { $user = User::find($request->id); $user->fcm_id = $request->token; $user->save(); } public function users_inquiries(Request $request) { $offset = $request->input('offset', 0); $limit = $request->input('limit', 10); $sort = $request->input('sort', 'sequence'); $order = $request->input('order', 'ASC'); $sql = Contactrequests::orderBy($sort, $order); if (isset($_GET['search']) && !empty($_GET['search'])) { $search = $_GET['search']; $sql->where('id', 'LIKE', "%$search%")->orwhere('email', 'LIKE', "%$search%")->orwhere('first_name', 'LIKE', "%$search%")->orwhere('last_name', 'LIKE', "%$search%"); } $total = $sql->count(); if (isset($_GET['limit'])) { $sql->skip($offset)->take($limit); } $res = $sql->get(); $bulkData = array(); $bulkData['total'] = $total; $rows = array(); $tempRow = array(); $count = 1; foreach ($res as $row) { $tempRow = $row->toArray(); $tempRow['email'] = '
' . $row->email . '
'; $tempRow['action'] = BootstrapTableService::deleteButton(route('destroy_contact_request', $row->id), $row->id); $rows[] = $tempRow; $count++; } $bulkData['rows'] = $rows; return response()->json($bulkData); } public function destroy_contact_request($id) { $contactrequest = Contactrequests::find($id); if ($contactrequest->delete()) { if ($contactrequest->image != '') { $url = $contactrequest->image; $relativePath = parse_url($url, PHP_URL_PATH); if (file_exists(public_path() . $relativePath)) { unlink(public_path() . $relativePath); } } ResponseService::successRedirectResponse('Contact Request Deleted Successfully'); } else { ResponseService::errorRedirectResponse('Something Went Wrong'); } } }