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


PHP User::findorFail方法代码示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update($id, Requests\UserRequest $request)
 {
     $user = User::findorFail($id);
     $user->update($request->all());
     session()->flash('flash_message', 'User Successfully Updated!');
     return redirect('users/' . $id . '');
 }
开发者ID:Gadurp1,项目名称:KD-2,代码行数:14,代码来源:UserController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(PostCreate $request)
 {
     $user = User::findorFail(Auth::user()->id);
     $post = new Post();
     $post->title = $request->input('title');
     $post->body = $request->input('body');
     $user->Post()->save($post);
     $imageName = $post->id . '.' . $request->file('image')->getClientOriginalExtension();
     $request->file('image')->move(base_path() . '/public/Images', $imageName);
     return redirect('posts');
 }
开发者ID:qarlson,项目名称:infr,代码行数:17,代码来源:PostsController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = User::findorFail(1);
     $trans = new Transaction();
     foreach ($request->all() as $key => $value) {
         $trans->{$key} = $value;
     }
     //$transaction = $user->transaction()->create($request->all());
     $newtransaction = $user->transaction()->save($trans);
     return response()->success(compact('newtransaction'));
 }
开发者ID:fusedtechresource,项目名称:peramax,代码行数:17,代码来源:TransactionController.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $user = User::findorFail(1);
     $name = $user->first_name;
     return $user->getFirstName($name);
 }
开发者ID:jokamjohn,项目名称:Accessors,代码行数:11,代码来源:UserController.php

示例5: stores

 public function stores($id)
 {
     $user = User::findorFail($id);
     return view('user.stores', compact('user'));
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:5,代码来源:UserController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $user = User::findorFail($id);
     $user->delete();
     return redirect()->route('users.index');
 }
开发者ID:tykus,项目名称:RockCRM,代码行数:12,代码来源:UsersController.php

示例7: userprofilephoto

 public function userprofilephoto(Request $request, $id)
 {
     //$file= $request->file('file');
     //$name= time(). $file->getClientOriginalName();
     //$file->move('biz/profile/photos', $name);
     //$biz= \App\Biz::findOrFail($id);
     //$biz->photos()->create(['path'=>"/biz/photos/{$name}"]);
     //return 'Done';
     $picture = ['image' => $request->file('image')];
     $rules = ['image' => 'required|image|mimes:jpeg,jpg,bmp,png,gif'];
     $validator = \Validator::make($picture, $rules);
     if ($validator->passes()) {
         $user_id = $request->get('id');
         $user = \App\User::findorFail($user_id);
         $profilePhoto = $user->profilePhoto;
         $image = $request->file('image');
         $name = time() . $image->getClientOriginalName();
         $image->move('user/profile', $name);
         if (!isset($profilePhoto->image)) {
             $pic = new \App\ProfilePhoto();
             $pic->image = 'user/profile/' . $name;
             $user->profilePhoto()->save($pic);
             return \Redirect::back()->with('message', 'profile photo added!!!');
         }
         if (isset($profilePhoto->image)) {
             $profilePhoto->image = 'user/profile/' . $name;
             $user->profilePhoto()->save($profilePhoto);
             return \Redirect::back()->with('message', ' profile photo updated!');
         }
     }
     return \Redirect::back()->with('errors', $validator->messages());
 }
开发者ID:samizares,项目名称:Ndibiz-laravel,代码行数:32,代码来源:HomeController.php

示例8: show

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function show($id)
 {
     $user = User::findorFail($id);
     $tasks = Task::where('assignedTo', $id)->get();
     return view('users.show', compact('user', 'tasks'));
 }
开发者ID:rbmulani7009,项目名称:laravel-test,代码行数:11,代码来源:UsersController.php

示例9: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update($id, EditUserRequest $request)
 {
     $role = Auth::user()->role_id;
     $user_id = Auth::user()->id;
     if ($role == 3 && $user_id != $id) {
         \Session::flash('message', 'Not Authorized to edit other users profile');
         \Session::flash('message-type', 'danger');
         return redirect('/user/' . $user_id);
     }
     $input = $request->all();
     $users = User::findorFail($id);
     if (isset($input['password'])) {
         $input['password'] = bcrypt($input['password']);
         $users->update($input);
     } else {
         unset($input['password']);
         $users->update($input);
     }
     \Session::flash('message', 'User has been updated!');
     \Session::flash('message-type', 'success');
     return redirect('/user/' . $id);
 }
开发者ID:raj-uimatic,项目名称:reportingapp,代码行数:29,代码来源:UsersController.php


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