当前位置: 首页>>代码示例>>PHP>>正文


PHP User::findOrFail方法代码示例

本文整理汇总了PHP中app\models\User::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findOrFail方法的具体用法?PHP User::findOrFail怎么用?PHP User::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: destroy

 /**
  * Removes the specified permission from the specified user.
  *
  * @param int|string $userId
  * @param int|string $permissionId
  *
  * @return int
  */
 public function destroy($userId, $permissionId)
 {
     $this->authorize('admin.users.permissions.destroy');
     $user = $this->user->findOrFail($userId);
     $permission = $user->permissions()->findOrFail($permissionId);
     return $user->permissions()->detach($permission);
 }
开发者ID:stevebauman,项目名称:administration,代码行数:15,代码来源:UserPermissionProcessor.php

示例2: destroy

 /**
  * Removes the specified permission from the specified user.
  *
  * @param int|string $userId
  * @param int|string $permissionId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($userId, $permissionId)
 {
     $this->authorize('admin.users.permissions.destroy');
     $user = $this->user->findOrFail($userId);
     $permission = $user->permissions()->findOrFail($permissionId);
     if ($user->permissions()->detach($permission)) {
         flash()->success('Success!', 'Successfully removed permission.');
         return redirect()->route('admin.users.show', [$userId]);
     }
     flash()->error('Error!', 'There was an issue removing this permission. Please try again.');
     return redirect()->route('admin.users.show', [$userId]);
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:20,代码来源:UserPermissionController.php

示例3: postUpdate

 /**
  * 更新密码.
  *
  * @param Request $request
  * @param int     $id
  *
  * @return Response
  */
 public function postUpdate(Request $request, $id)
 {
     $rules = ['password' => 'required|min:6|confirmed'];
     $this->validate($request, $rules);
     $user = User::findOrFail($id)->update(['password' => Hash::make($request->password)]);
     return redirect()->back()->withMessage('更新成功!');
 }
开发者ID:wmk223,项目名称:site,代码行数:15,代码来源:UserController.php

示例4: handle

 /**
  * Execute the job.
  *
  */
 public function handle()
 {
     $user = User::findOrFail(1);
     $status = 1;
     $mail = event(new LoginEvent($user, $status));
     return $mail;
 }
开发者ID:tccLaravel,项目名称:learn,代码行数:11,代码来源:sendEmailJob.php

示例5: send

 public static function send($from, $to, $subject, $content)
 {
     if (empty($subject)) {
         return 'Subject must not be empty';
     }
     if (empty($content)) {
         return 'Content must not be empty';
     }
     try {
         if (!is_object($from)) {
             $from = User::findOrFail($from);
         }
         if (!is_object($to)) {
             $to = User::findOrFail($to);
         }
     } catch (ModelNotFoundException $e) {
         return false;
     }
     $message = new static();
     $message->from = $from->id;
     $message->to = $to->id;
     $message->subject = $subject;
     $message->content = $content;
     $message->save();
     return $message;
 }
开发者ID:holzmaster,项目名称:w0bm.com,代码行数:26,代码来源:Message.php

示例6: update

 public function update($userId, Request $request)
 {
     $user = User::findOrFail($userId);
     $user->fill($request->all());
     $user->save();
     return Redirect::back()->with(['success' => 'User ' . $user->name . ' was changed']);
 }
开发者ID:blozixdextr,项目名称:adtw,代码行数:7,代码来源:UserController.php

示例7: postEdit

 /**
  * Update user details
  *
  * @param Request $request
  * @return Response
  */
 public function postEdit(Request $request)
 {
     $data = $request->all();
     $user = User::findOrFail(Auth::user()->id);
     $user->fill($data)->save();
     $user->touch();
     return redirect()->action('UserController@getEdit')->with('message', array('info', 'Profile information updated.'));
 }
开发者ID:Groopy,项目名称:groopyio,代码行数:14,代码来源:UserController.php

示例8: putUseractive

 public function putUseractive($periodo_id)
 {
     $user = User::fromToken();
     $usuario = User::findOrFail($user->user_id);
     $usuario->periodo_id = $periodo_id;
     $usuario->save();
     return $usuario;
 }
开发者ID:bluesky777,项目名称:5myvc,代码行数:8,代码来源:PeriodosController.php

示例9: update

 /**
  * Update a user.
  *
  * @param UserUpdateRequest $request
  * @param int               $id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function update(UserUpdateRequest $request, $id)
 {
     $data = $request->only('name', 'email');
     if ($password = $request->input('password')) {
         $data['password'] = Hash::make($password);
     }
     return response()->json(User::findOrFail($id)->update($data));
 }
开发者ID:vvdcect,项目名称:koel,代码行数:16,代码来源:UserController.php

示例10: show

public function show($id){
try{
$user = User::findOrFail($id);
return view('home',['user' => $user]);
}catch(ModelNotFoundException $e){
return view('errors.404');
}
}
开发者ID:RybinDen,项目名称:laravel-blog,代码行数:8,代码来源:UserController.php

示例11: show

 public function show($id)
 {
     $user = User::findOrFail($id);
     echo "{$user->name}" . "<br>";
     echo "{$user->open_id}" . "<br>";
     echo "{$user->introduction}" . "<br>";
     echo $user->favorites;
 }
开发者ID:KIDJourney,项目名称:edutube,代码行数:8,代码来源:UserController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     #find user
     $user = User::findOrFail($id);
     #skin to call
     $view = 'skins.skin_b.user.show';
     #call the view with the user
     return view($view, ['user' => $user]);
 }
开发者ID:nkiermaier,项目名称:laravel_ecommerce,代码行数:15,代码来源:UserController.php

示例13: get

 public function get($id)
 {
     try {
         $user = User::findOrFail($id);
     } catch (\Exception $e) {
         return parent::response(['success' => false, 'error' => "User not found"]);
     }
     return $user;
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:9,代码来源:UserController.php

示例14: update

 /**
  * Approves startup membership for the specified user
  * Get /startups/{startupUrl}/membership/{userId}/approve
  *
  * @param $startup
  * @param $user
  * @param $action
  * @return Response
  */
 public function update($startup, $user, $action)
 {
     $startup = Startup::where('url', '=', $startup)->firstOrFail();
     if ($this->currentUserIsOwner($startup->owner)) {
         $user = User::findOrFail($user);
         $this->dispatch(new UpdateMembership($user, $startup, $action));
     }
     return Redirect::route('startups.show', ['url' => $startup->url]);
 }
开发者ID:katzumi,项目名称:talent4startups,代码行数:18,代码来源:MembershipController.php

示例15: destroyUser

 public function destroyUser($id)
 {
     $authUser = Auth::user();
     $user = User::findOrFail($id);
     if ($user->id == $authUser->id) {
         return -1;
     }
     $result = User::destroy($id);
     return $result;
 }
开发者ID:jaumesala,项目名称:opendata-maps,代码行数:10,代码来源:UserRepository.php


注:本文中的app\models\User::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。