當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。