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


PHP User::firstOrCreate方法代码示例

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


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

示例1: handleFbCallback

 public function handleFbCallback()
 {
     $fb_user = Socialite::driver('facebook')->user();
     $user = User::firstOrCreate(['firstname' => $fb_user->user['first_name'], 'lastname' => $fb_user->user['last_name'], 'email' => $fb_user->email]);
     Auth::login($user, true);
     return Redirect::to('/books');
 }
开发者ID:a1ex7,项目名称:librauth,代码行数:7,代码来源:AuthController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = \App\User::firstOrCreate(['email' => 'orange@edward.com']);
     $user->name = 'Orange';
     $user->email = 'orange@edward.com';
     $user->password = \Hash::make('helloworld');
     $user->user_role = 'leader';
     $user->user_group = 'Orange Fellowship';
     $user->user_verified = true;
     $user->save();
     $user = \App\User::firstOrCreate(['email' => 'jill@harvard.edu']);
     $user->name = 'Jill';
     $user->email = 'jill@harvard.edu';
     $user->password = \Hash::make('helloworld');
     $user->user_role = 'leader';
     $user->user_group = 'Joshua 1 Fellowship';
     $user->user_verified = false;
     $user->save();
     $user = \App\User::firstOrCreate(['email' => 'jamal@harvard.edu']);
     $user->name = 'Jamal';
     $user->email = 'jamal@harvard.edu';
     $user->password = \Hash::make('helloworld');
     $user->user_role = 'admin';
     $user->user_group = 'Global';
     $user->user_verified = true;
     $user->save();
     $user = \App\User::firstOrCreate(['email' => 'jack@harvard.edu']);
     $user->name = 'Jack';
     $user->email = 'jack@harvard.edu';
     $user->password = \Hash::make('helloworld');
     $user->user_role = 'viewer';
     $user->user_group = 'Joshua 1 Fellowship';
     $user->user_verified = true;
     $user->save();
 }
开发者ID:oredla,项目名称:p4,代码行数:40,代码来源:UsersTableSeeder.php

示例3: Usuarios

 public function Usuarios($action = null)
 {
     if (isset($action)) {
         if ($action == "create") {
             $data = User::firstOrCreate(Input::except("_token", "_user"));
             return $respuesta = array('Record' => $data, 'Result' => "OK");
         }
         if ($action == "edit") {
             User::where("id", Input::get("id"))->update(Input::except("_token", "id", "_user"));
             return $respuesta = array('Record' => User::find(Input::get('id')), 'Result' => "OK");
         }
         if ($action == "remove") {
             User::where('id', Input::get("id"))->delete();
             return '{"Result":"OK"}';
         }
         if ($action == "list") {
             $Records = User::get();
             $respuesta = array('Records' => $Records, 'Result' => "OK");
             return json_encode($respuesta);
         }
         if ($action == "empresas") {
             $nulos = DB::table('empresas')->select(DB::raw("'NO POSEE' as DisplayText, NULL as Value"));
             $respuesta = DB::table('empresas')->select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'asc')->distinct()->get();
             return "var opciones=" . json_encode($respuesta);
         }
     }
 }
开发者ID:seedgabo,项目名称:DirectvMAC,代码行数:27,代码来源:AjaxController.php

示例4: authenticate

 /**
  * authenticate
  *
  * @param  Request  $request
  * @return Response
  */
 public function authenticate(Request $request)
 {
     $code = $request->input('code');
     if ($code) {
         $token = $this->api->tokenExchange($code);
         if (isset($token->athlete)) {
             // changing to use email instead of access token since access token apparently changes
             $user = User::firstOrCreate(['email' => $token->athlete->email]);
             if (!$user->strava_token) {
                 Mail::send('emails.newuser', ['name' => $token->athlete->firstname . " " . $token->athlete->lastname], function ($message) {
                     $message->from('admin@stravabestefforts.com', 'Strava BE');
                     $message->to(env('MANDRILL_EMAIL'), 'Austin Ducworth')->subject('New Strava BE User');
                 });
             }
             // fill in data
             $user->strava_token = $token->access_token;
             $user->name = $token->athlete->firstname . " " . $token->athlete->lastname;
             $user->profile_medium = $token->athlete->profile_medium;
             $user->city = $token->athlete->city;
             $user->state = $token->athlete->state;
             $user->country = $token->athlete->country;
             $user->sex = $token->athlete->sex;
             $user->premium = $token->athlete->premium;
             $user->date_preference = $token->athlete->date_preference;
             $user->measurement_preference = $token->athlete->measurement_preference;
             $user->email = $token->athlete->email;
             $user->password = bcrypt('stravapassword');
             $user->save();
             if (Auth::attempt(['email' => $token->athlete->email, 'password' => 'stravapassword'])) {
                 return redirect()->intended('strava/running');
             }
         }
     }
 }
开发者ID:aducworth,项目名称:strava-best-efforts,代码行数:40,代码来源:StravaController.php

示例5: callback

 /**
  * Callback action that should be called by auth0, logs the user in
  */
 public function callback()
 {
     // Get a handle of the Auth0 service (we don't know if it has an alias)
     $service = \App::make('auth0');
     // Try to get the user information
     $profile = $service->getUser();
     // Get the user related to the profile
     $auth0User = $this->userRepository->getUserByUserInfo($profile);
     if ($auth0User) {
         if (!str_contains($auth0User->name, '@')) {
             $name = $auth0User->name;
         } else {
             $name = $auth0User->nickname;
         }
         // If we have a user, we are going to log him in, but if
         // there is an onLogin defined we need to allow the Laravel developer
         // to implement the user as he wants an also let him store it.
         $flight = User::firstOrCreate(['github_id' => $auth0User->user_id, 'email' => $auth0User->email, 'picture' => $auth0User->picture, 'name' => $name]);
         if ($service->hasOnLogin()) {
             $user = $service->callOnLogin($auth0User);
         } else {
             // If not, the user will be fine
             $user = $auth0User;
         }
         \Auth::login($user);
     }
     return \Redirect::intended('/');
 }
开发者ID:sgf-web-devs,项目名称:sgf-winner,代码行数:31,代码来源:Auth0Controller.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //User 1
     //Necessary user columns
     $user = \App\User::firstOrCreate(['email' => 'jill@harvard.edu']);
     $user->name = 'Jill';
     $user->email = 'jill@harvard.edu';
     $user->password = \Hash::make('helloworld');
     //User profile columns
     $user->birthday = Carbon\Carbon::now()->subYears(21);
     $user->gender = 'Woman';
     $user->pronouns = "she/her";
     $user->save();
     //User 2 - used to demonstrate inability to access posts by a user you are not sign in as
     //Necessary user columns
     $user = \App\User::firstOrCreate(['email' => 'jamal@harvard.edu']);
     $user->name = 'Jamal';
     $user->email = 'jamal@harvard.edu';
     $user->password = \Hash::make('helloworld');
     //User profile columns
     $user->birthday = Carbon\Carbon::now()->subDays(20)->subYears(28);
     $user->gender = 'Man';
     $user->pronouns = "he/him";
     $user->save();
     //User 3 - used to demonstrate how a lack of posts or profile information is handled
     //Necessary user columns
     $user = \App\User::firstOrCreate(['email' => 'jan@harvard.edu']);
     $user->name = 'Jan';
     $user->email = 'jan@harvard.edu';
     $user->password = \Hash::make('helloworld');
     $user->save();
 }
开发者ID:practicalmess,项目名称:transtracker,代码行数:37,代码来源:UsersTableSeeder.php

示例7: handleProviderCallback

 /**
  * Obtain the user information from Google..
  *
  * @return Response
  */
 public function handleProviderCallback(Request $request)
 {
     $googleUser = Socialite::driver('google')->user();
     $user = User::firstOrCreate(['email' => $googleUser->getEmail(), 'name' => $googleUser->getName()]);
     Auth::login($user);
     $request->session()->put('user', Auth::user());
     return redirect('/consejo');
 }
开发者ID:krusty,项目名称:transparenciaCF,代码行数:13,代码来源:SocialAuthController.php

示例8: login

 public function login(Request $request)
 {
     $token = $request['id_token'];
     $user_data = $this->create_gclient($token);
     $user = User::firstOrCreate(['name' => $user_data['name'], 'email' => $user_data['email']]);
     Auth::login($user);
     return redirect(route('user.show'));
 }
开发者ID:AUCSC,项目名称:sac,代码行数:8,代码来源:StaticPagesController.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = \App\User::firstOrCreate(['email' => 'john@harvard.edu']);
     $user->name = 'John';
     $user->email = 'john@harvard.edu';
     $user->password = \Hash::make('helloworld');
     $user->save();
 }
开发者ID:jpedroza,项目名称:laravelvideobooks.aacax.net,代码行数:13,代码来源:UsersTableSeeder.php

示例10: getLogin

 /**
  * Store a newly created resource in storage.
  * @Get("/{provider}/callback", as="social.login.getLogin")
  * @param string $provider
  * @return \Illuminate\Http\Response
  */
 public function getLogin($provider)
 {
     $userData = Socialite::with($provider)->user();
     Log::debug(print_r($userData, true));
     $user = User::firstOrCreate(['username' => $userData->nickname, 'email' => $userData->email]);
     Auth::login($user);
     return response()->redirectToRoute('articles.getIndex');
 }
开发者ID:picolit,项目名称:bbs,代码行数:14,代码来源:SocialLoginController.php

示例11: findByUsernameOrCreate

 public function findByUsernameOrCreate($userData)
 {
     $user = User::where('email', '=', $userData->email)->first();
     if (!$user) {
         return User::firstOrCreate(['name' => $userData->name, 'email' => $userData->email]);
     }
     return $user;
 }
开发者ID:jamesvillarrubia,项目名称:tpp,代码行数:8,代码来源:UserRepository.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $posts = factory(Post::class, 10)->create();
     $user = \App\User::firstOrCreate(['name' => 'helfull', 'email' => 'admin@helfull.de']);
     $posts->each(function ($post) use($user) {
         $post->user()->associate($user);
         $post->save();
     });
 }
开发者ID:burnedcms,项目名称:modules,代码行数:14,代码来源:PostSeeder.php

示例13: store

 public function store(Request $request)
 {
     $user = User::firstOrCreate(['name' => $request->name, 'email' => $request->email, 'password' => bcrypt($request->password)]);
     if ($request->input('role_list')) {
         $user->roles()->sync($request->input('role_list'));
     }
     Flash::success('User Created!');
     return redirect()->action('UserController@index');
 }
开发者ID:tindase,项目名称:uc-insight,代码行数:9,代码来源:UserController.php

示例14: findByUsernameOrCreate

 public function findByUsernameOrCreate($userData, $socialiteName)
 {
     if ($socialiteName == 'weibo') {
         return User::firstOrCreate(['name' => $userData->nickname, 'avatar' => $userData->avatar, 'weibo_id' => $userData->id]);
     } elseif ($socialiteName == 'weixin') {
         return User::firstOrCreate(['name' => $userData->nickname, 'avatar' => $userData->headimgurl, 'weixin_id' => $userData->openid]);
     } elseif ($socialiteName = 'github') {
         return User::firstOrCreate(['name' => $userData->id, 'nickname' => $userData->nickname, 'avatar' => $userData->avatar]);
     }
 }
开发者ID:nutsdo,项目名称:rp-wechat,代码行数:10,代码来源:UserRepository.php

示例15: findByUsernameOrCreate

 public function findByUsernameOrCreate($provider, $userData)
 {
     $user = User::firstOrCreate(['provider_id' => $userData->id, 'provider' => $provider]);
     $user->email = $userData->email;
     $user->name = $userData->name;
     $user->nickname = $userData->nickname;
     $user->avatar = $userData->avatar;
     $user->save();
     return $user;
 }
开发者ID:sjardim,项目名称:GA-Exam,代码行数:10,代码来源:UserRepository.php


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