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


PHP User::findOrNew方法代码示例

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


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

示例1: handle

 /**
  * Execute the job.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handle()
 {
     // Language.
     $language = Language::findOrNew(1);
     if (!$language->id) {
         $language->id = 1;
         $language->name = 'english';
         $language->prefix = 'en';
         $language->save();
     }
     // Country.
     $country = Country::findOrNew(1);
     if (!$country->id) {
         $country->id = 1;
         $country->name = 'spain';
         $country->prefix = 'spa';
         $country->save();
     }
     // User.
     $user = User::findOrNew(1);
     if (!$user->id) {
         $user->id = 1;
         $user->name = 'Test';
         $user->surname = 'Test';
         $user->email = 'test@test.com';
         $user->direction = 'this should be called address lol';
         $user->birthday = '2000-01-01';
         $user->language_id = $language->id;
         $user->country_id = $country->id;
         $user->save();
     }
     $created = $user->tasks()->create($this->requestParams);
     return response()->json($created);
 }
开发者ID:juboba,项目名称:Luminosity,代码行数:39,代码来源:CreateTaskJob.php

示例2: viewUserProfile

 /**
  * show users profile
  * @param $userId
  * @return \Illuminate\View\View
  */
 public function viewUserProfile($userId)
 {
     $userProfile = $this->user->findOrNew($userId);
     if (!in_array($userId, $this->organizationManager->getOrganizationUsers($this->org_id))) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     return view('admin.viewUserProfile', compact('userProfile'));
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:13,代码来源:AdminController.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy()
 {
     $user_id = Route::input('user_id');
     //dd('this is dengun');
     $user = User::findOrNew($user_id);
     $first_name = $user->first_name;
     $user->delete();
     return \redirect('admin/dashboard/showuser/selectuser')->with('delete', 'user with first name  ' . $first_name . '  deleted successfully');
 }
开发者ID:pius-ng3a,项目名称:go_orderdeliver,代码行数:15,代码来源:UsersController.php

示例4: postModificar

 public function postModificar(Request $req)
 {
     $usuario = User::findOrNew($req->get('id', 0));
     $usuario->fill($req->all());
     if ($req->get('password') != "") {
         $usuario->password = $req->get('password');
     }
     if ($usuario->save()) {
         return redirect('usuarios')->with('mensaje', 'Se actualizó el usuario correctamente');
     }
     return redirect()->back()->withInput()->withErrors($usuario->getErrors());
 }
开发者ID:armandolazarte,项目名称:amsrental-presupuestos,代码行数:12,代码来源:UsuariosController.php

示例5: createOrUpdate

 public function createOrUpdate($profile, $token)
 {
     if (!isset($profile->id)) {
         throw new \InvalidArgumentException('There must be an ID field');
     }
     $user = User::findOrNew($profile->id);
     if (is_null($user->id)) {
         $user->id = $profile->id;
     }
     $user = $user->fill(['name' => $profile->name, 'email' => $profile->email, 'picture' => $profile->picture, 'access_token' => $token]);
     $user->save();
     return $user;
 }
开发者ID:phpfour,项目名称:bangla-ocr,代码行数:13,代码来源:UserRepository.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if ($request->type == 1) {
         $person = \App\Dosen::findOrFail($request->id);
     } else {
         $person = \App\Mahasiswa::findOrFail($request->id);
     }
     $user = \App\User::findOrNew($request->id);
     $user->id = $request->id;
     $user->name = $person->nama;
     $user->email = $request->email;
     $user->password = bcrypt($request->password);
     $user->save();
     if ($request->type == '1') {
         return redirect('/dosen');
     } else {
         return redirect('/mahasiswa');
     }
 }
开发者ID:husnilk,项目名称:admin,代码行数:25,代码来源:UserController.php

示例7: postIndex

 /**
  * Store a newly created resource in storage.
  * Or
  * Update the specified resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postIndex(Request $request)
 {
     $usuario = User::findOrNew($request->input('id'));
     $usuario->fill($request->all());
     $validacion = $usuario->validate();
     if ($validacion) {
         if ($usuario->save()) {
             $usuario->roles()->sync($request->input('roles', []));
             if ($request->ajax()) {
                 return response()->json(['mensaje' => 'Se guardo el usuario correctamente']);
             } else {
                 return redirect('admin/seguridad/usuarios')->with('mensaje', 'Se guardo el usuario correctamente.');
             }
         } else {
             return back()->withInput()->withErrors($usuario->getErrors());
         }
     } else {
         return back()->withInput()->withErrors($usuario->getErrors());
     }
 }
开发者ID:reysmerwvr,项目名称:jenion,代码行数:29,代码来源:UsersController.php

示例8: getCallback

 /**
  * 社交登录回调
  */
 public function getCallback()
 {
     $platform = Input::get('platform');
     $info = Socialite::driver($platform)->user();
     $socialAccount = SocialAccount::whereId($info->id)->wherePlatform($platform)->first();
     if (!$socialAccount) {
         $socialAccount = SocialAccount::from($info, $platform);
         if (Auth::guest()) {
             $user = User::create();
             $user->nickname = $socialAccount->nickname;
             $user->avatar = $socialAccount->avatar;
             if ($platform == 'github') {
                 $user->email = $socialAccount->email;
             }
         } else {
             $user = User::findOrNew(Auth::id());
         }
         $user->social()->save($socialAccount);
         $user->save();
     }
     Auth::loginUsingId($socialAccount->user_id, true);
     return Redirect::to('/');
 }
开发者ID:imjerrybao,项目名称:PushApp,代码行数:26,代码来源:AuthController.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     error_log(print_r('UserController.destroy(' . $id . ')', TRUE));
     $user = User::findOrFail($id);
     $user->delete();
     $params = ['title' => 'Deleted User', 'user' => User::findOrNew($id)];
     return view('blog.user.destroy', $params);
 }
开发者ID:ambarsetyawan,项目名称:gday-laravel,代码行数:14,代码来源:UserController.php

示例10: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = User::findOrNew($id);
     return view('user.edit', compact('user'));
 }
开发者ID:NgoDucHai,项目名称:BlogLaravel5.1,代码行数:11,代码来源:AdminController.php

示例11: index

 /**
  * Get all tasks assigned to the current user.
  *
  * @return \Symfony\Component\HttpFoundation\Response Returns the tasks list.
  */
 public function index()
 {
     $tasks = User::findOrNew($this->user)->tasks;
     return response()->json($tasks);
 }
开发者ID:juboba,项目名称:Luminosity,代码行数:10,代码来源:TaskController.php

示例12: getAdmin

 public function getAdmin(Route $route)
 {
     $this->administador = User::findOrNew($route->getParameter('administrador'));
 }
开发者ID:ericray,项目名称:test,代码行数:4,代码来源:AdministradorController.php


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