本文整理汇总了PHP中app\User::findOrfail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findOrfail方法的具体用法?PHP User::findOrfail怎么用?PHP User::findOrfail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::findOrfail方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($id)
{
$user = User::findOrfail($id);
$histories = $user->histories;
$customer = $user->customer;
if (Gate::denies('show', $customer)) {
abort('403', 'Sorry, not sorry');
}
return view('customer.show', compact('histories', 'customer'));
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$validator = Validator::make($request->all(), ['email' => 'required|email', 'contact' => 'required|integer|max:9999999999']);
if ($validator->fails()) {
return redirect('/profile')->withErrors($validator)->withInput();
} else {
$user = User::findOrfail(Auth::user()->id);
$users = $user->update(['name' => ucwords($request->name), 'email' => $request->email, 'contact' => $request->contact, 'address' => $request->address]);
return Redirect::to('/home');
}
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Requests\EditUserRequest $request, $id)
{
$user = User::findOrfail($id);
$user->fill($request->all());
if ($request->password != null) {
$user->password = bcrypt($request->password);
}
dd($user->password);
$user->save();
session::flash('message', 'Usuario editado de los registros');
return redirect()->route('admin.users.index');
}
示例4: admin
public function admin($id)
{
$user = User::findOrfail($id);
if ($user->admin == 1) {
$admin = 0;
}
if ($user->admin == 0) {
$admin = 1;
}
$user->admin = $admin;
$user->save();
Flash::success('সঠিক ভাবে সম্পন্ন হয়েছে।');
return redirect()->back();
}
示例5: delete
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function delete($id)
{
// dd($id);
$dataUser = User::findOrfail($id);
$dataUse = User::where('id', $id)->get();
foreach ($dataUse as $d) {
$admin_id = $d->user_id;
}
$data = AdminModel::findOrfail($admin_id);
$dataUser->delete($id);
$data->delete($admin_id);
return back()->with('message', 'admin data delete successfully.....');
}
示例6: delete
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function delete($id)
{
// dd($id);
$dataUser = User::findOrfail($id);
$dataUse = User::where('id', $id)->get();
foreach ($dataUse as $d) {
$user_id = $d->user_id;
}
$data = UserModel::findOrfail($user_id);
$dataUser->delete($id);
$data->delete($user_id);
return redirect()->route('user_manage')->with('message', 'user data delete successfully.....');
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$user = User::findOrfail($id);
return view('User.show', compact('user'));
}
示例8: password
public function password(Request $request)
{
$this->validate($request, ['password' => 'required|confirmed|min:6']);
$id = Auth::user()->id;
$password = User::findOrfail($id);
$password->password = bcrypt($request->password);
$password->save();
Flash::success('আপনি সঠিক ভাবে সম্পাদন করেছেন!');
return redirect()->back();
}
示例9: postChangePassword
public function postChangePassword(Request $request)
{
$data = $request->except('_token');
if (!ServiceAccount::checkCaptcha($data)) {
return redirect()->route('user.get.changePassword');
} else {
if ($data['new_password'] != $data['rePass'] || strlen($data['new_password']) < 6 || strlen($data['new_password']) > 15) {
return redirect()->route('user.get.changePassword')->with('message', 'Password mới phải trùng nhau và ký tự >6 và <15.');
}
if (\Hash::check($data['password'], Auth::user()->password)) {
$user = User::findOrfail(Auth::user()->id);
//dd($data);
$user->password = \Hash::make($data['new_password']);
$user->save();
$model = new GAccount();
//check all user if exsit on all server game
$servers = Server::all();
foreach ($servers as $server) {
$model->setConnection($server->user_db);
try {
$account = $model->where('loginName', $user->username)->first();
} catch (\Exception $e) {
return redirect()->route('user.register')->with('error', 'có lỗi!');
}
$account->password_hash = ServiceAccount::getPassword($data['new_password']);
$account->save();
}
return redirect()->route('user.profile')->with('message', 'Đổi mật khẩu thành công!');
}
}
}