/** * Function to update data was just edited to database * @param id: id of category that want edit * @param alias : name of category that want edit. it was rewritten * @param request: validate input of data for category */ public function update(EditUserRequest $request, $id) { $user = User::find($id); $file = $request->file('avatar'); if (isset($file)) { $avatar = $file->getClientOriginalName(); if (isset($user->avatar)) { $des = base_path() . '/public/upload/images/' . $user->avatar; if (file_exists($des)) { unlink($des); } $request->file('avatar')->move(base_path() . '/public/upload/images/', $avatar); } } else { $avatar = $user->avatar; } $user->update(['name' => $request->input('name'), 'email' => $request->input('email'), 'password' => Hash::make($request->input('password')), 'avatar' => $avatar, 'role' => $request->get('radios')]); return redirect()->route('admin.user.index')->with(['flash_message' => 'Edited Success!!!', 'flash_level' => 'success']); }
/** * Author page */ public function authorIndex($id) { $articles_user = Article::where('user_id', $id)->simplePaginate(5); $author = User::find($id); return view('front-end.pages.author', compact('articles_user', 'author')); }