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


PHP User::firstOrNew方法代码示例

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


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

示例1: diakkeszites

 private function diakkeszites($file)
 {
     $egyvaltozo1 = Excel::load($file, function ($reader) {
         $reader->ignoreEmpty();
     })->get(array('hallgatoneptunkodja'))->toArray();
     try {
         $szamol = User::all()->count();
         foreach ($egyvaltozo1 as $egyvaltozo) {
             if ($egyvaltozo["hallgatoneptunkodja"] != "") {
                 $diak = User::firstOrNew(array("name" => $egyvaltozo["hallgatoneptunkodja"], "email" => $egyvaltozo["hallgatoneptunkodja"], "type" => "3"));
                 if (empty($diak->password)) {
                     $diak->password = bcrypt($egyvaltozo["hallgatoneptunkodja"]);
                     $diak->save();
                 } else {
                     $diak->active = 1;
                     $diak->save();
                 }
             }
         }
         $szamol = User::all()->count() - $szamol;
         return $szamol;
     } catch (\Exception $e) {
         $message = "Import file is not valid! Please check";
         return view('import.error', compact('message'));
     }
 }
开发者ID:hevelebalazs,项目名称:survey,代码行数:26,代码来源:ImportController.php

示例2: handle

 public function handle()
 {
     $adminUser = User::firstOrNew(['email' => env('ADMIN_EMAIL'), 'name' => 'Cocoaheads Admin']);
     $adminUser->password = Hash::make(env('ADMIN_PASSWORD'));
     $adminUser->save();
     $this->info("Admin User id {$adminUser->id}");
 }
开发者ID:melbournecocoa,项目名称:website,代码行数:7,代码来源:CreateAdmin.php

示例3: store

 public function store(BookingRequest $request)
 {
     $booking = array('car_type_id' => $request->car_type_id, 'number_of_passengers' => $request->number_of_passengers, 'pickup_time' => $request->pickup_date_part . ' ' . $request->pickup_time_part, 'ip_info' => $request->ip_info);
     $newBooking = Booking::create($booking);
     flash()->success('Your booking has been created!')->important();
     if (!empty($request->comment1)) {
         //children comment
         $comment1 = array('booking_id' => $newBooking->id, 'comment_type_id' => '1', 'role_id' => '1', 'comment' => $request->comment1);
         Comment::create($comment1);
     }
     if (!empty($request->comment2)) {
         //general comment
         $comment2 = array('booking_id' => $newBooking->id, 'comment_type_id' => '2', 'role_id' => '1', 'comment' => $request->comment2);
         Comment::create($comment2);
     }
     $change = array('booking_id' => $newBooking->id, 'change_type_id' => '4', 'user_id' => Auth::user()->id, 'from' => null, 'to' => null);
     Change::create($change);
     $passenger = User::firstOrNew(['email' => $request->email]);
     $passenger->name = $request->name;
     $passenger->phone = $request->phone;
     $passenger->save();
     $role = array('booking_id' => $newBooking->id, 'role_type_id' => '2', 'user_id' => $passenger->id);
     Role::create($role);
     $price = array('booking_id' => $newBooking->id, 'income_type_id' => '1', 'amount_eur' => $request->price);
     Income::create($price);
     $locationArray = $request->location;
     foreach ($request->address as $order => $address_id) {
         $route_point = null;
         $route_point = array('booking_id' => $newBooking->id, 'location_id' => $locationArray[$order], 'address_id' => $address_id, 'order' => $order);
         Route_point::create($route_point);
     }
     return redirect('bookings');
 }
开发者ID:jedlicka82,项目名称:transferpraha,代码行数:33,代码来源:BookingController.php

示例4: register

 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('App\\User', function ($app) {
         // Session中获取当前认证用户
         $authUser = session('logged_user');
         if (true || app()->environment('debug')) {
             $authUser = (object) array('id' => 'Hello, World!');
         }
         if (empty($authUser)) {
             $oauth = app('wechat')->oauth;
             try {
                 $authUser = $oauth->user();
             } catch (\InvalidArgumentException $e) {
                 $response = $oauth->scopes(['snsapi_base'])->redirect();
                 return $response;
             }
             // 保存Session
             //$authUser = $oauth->user();
             session(['logged_user' => $authUser]);
         }
         // 根据认证得到的用户openid获取用户信息,若不存在则实例化新用户
         $user = User::firstOrNew(['openid' => $authUser->id]);
         if ($user->state == 'normal' && $user->score <= 0) {
             $user->state = 'disabled';
             $user->save();
         } else {
             if ($user->score > 0 && $user->state == 'disabled' && $user->free_at && $user->free_at->lte(Carbon::now())) {
                 $user->state = 'normal';
                 $user->save();
             }
         }
         return $user;
     });
 }
开发者ID:xuhongxu96,项目名称:tagexing2,代码行数:39,代码来源:AppServiceProvider.php

示例5: findOrCreateUser

 public function findOrCreateUser($googleUser)
 {
     $authUser = User::firstOrNew(['email' => $googleUser->email]);
     $authUser->token = Crypt::encrypt(json_encode($googleUser->token));
     $authUser->save();
     return $authUser;
 }
开发者ID:baopham,项目名称:gdrive-comments,代码行数:7,代码来源:AuthController.php

示例6: findByEmailOrCreate

 /**
  * Given an array of formatted user data,
  * return a valid user model
  *
  * @param array $userData
  * @return static
  */
 public function findByEmailOrCreate($userData)
 {
     //find user by email
     $user = User::firstOrNew(['email' => $userData['email']]);
     //save all new data to the record
     $user->save($userData);
     return $user;
 }
开发者ID:banderon1,项目名称:faces,代码行数:15,代码来源:UserRepository.php

示例7: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     $gitUser = Socialite::driver('github')->user();
     $user = User::firstOrNew(['username' => $gitUser->nickname, 'name' => $gitUser->name, 'email' => $gitUser->email]);
     $user->github_token = $gitUser->token;
     $user->save();
     auth()->login($user);
     return redirect('/gists');
 }
开发者ID:ilmala,项目名称:snippets,代码行数:14,代码来源:AuthController.php

示例8: getFacebookCallback

 public function getFacebookCallback(Request $req)
 {
     $user = \Socialite::with('facebook')->user();
     $data = array('name' => $user->name, 'email' => $user->email, 'password' => $req['code']);
     $request = new Request();
     $request = User::firstOrNew($data);
     $request->save();
     Auth::login($request);
     return redirect('');
 }
开发者ID:anmolarora,项目名称:MyBlog_PHP,代码行数:10,代码来源:UserController.php

示例9: handleProviderCallback

 /**
  * Obtain the user information from FaceBook.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     $user = Socialite::driver('facebook')->user();
     // create in database if null
     $save = User::firstOrNew(array('name' => $user->getName(), 'username' => $user->getNickname(), 'email' => $user->getEmail(), 'avatar' => $user->getAvatar(), 'provider' => 'facebook', 'provider_id' => $user->getId()));
     $save->save();
     //put id and name into session
     Session::put('provider_id', $user->getId());
     Session::put('name', $user->getName());
     return redirect('/main');
 }
开发者ID:DavidH46,项目名称:Meetme,代码行数:16,代码来源:AuthController.php

示例10: requireAuthenticationForRoute

 public function requireAuthenticationForRoute(FunctionalTester $I)
 {
     $I->dontSeeAuthentication();
     $I->amOnPage('/secure');
     $I->seeCurrentUrlEquals('/auth/login');
     $I->see('Login');
     $I->amLoggedAs(User::firstOrNew($this->userAttributes));
     $I->amOnPage('/secure');
     $I->seeResponseCodeIs(200);
     $I->see('Hello World');
 }
开发者ID:jenky,项目名称:laravel-api-starter,代码行数:11,代码来源:AuthCest.php

示例11: findByEmailOrCreate

 public function findByEmailOrCreate($userData)
 {
     $user = User::firstOrNew(['email' => $userData->email]);
     if (!$user->exists) {
         $name = $this->splitName($userData->name);
         $user->f_name = $name[0];
         $user->l_name = $name[1];
         $user->save();
     }
     return $user;
 }
开发者ID:steveperrito,项目名称:flora-laravel,代码行数:11,代码来源:UserRepository.php

示例12: handleProviderCallback

 /**
  * Obtain the user information from Facebook.
  * 
  * @return Response
  */
 public function handleProviderCallback()
 {
     $user = Socialite::driver('facebook')->user();
     $newUser = User::firstOrNew(['email' => $user->email]);
     $newUser->name = $user->name;
     $newUser->facebook_id = $user->id;
     $newUser->first_name = $user->user['first_name'];
     $newUser->last_name = $user->user['last_name'];
     $newUser->save();
     //        dd($newUser);
     Auth::login($newUser, true);
     return redirect(route('alerts.index'));
 }
开发者ID:GregKaleka,项目名称:CommutePop,代码行数:18,代码来源:AuthController.php

示例13: updateUsers

 private function updateUsers($data)
 {
     foreach ($data as $row) {
         $user = User::firstOrNew(['id' => $row->id]);
         $user->name = $row->name;
         $user->email = $row->email;
         $user->thumb_url = $row->thumb_url;
         $user->about = $row->about;
         $user->phone = $row->phone;
         $user->facebook = $row->facebook;
         $user->save();
     }
     return '/admin/user';
 }
开发者ID:punkrockio,项目名称:Sample-Web-App,代码行数:14,代码来源:CmsController.php

示例14: socialCallback

 public function socialCallback($provider)
 {
     $socialProviderType = SocialProviderType::where('name', $provider)->first();
     $socialProviderData = Socialize::with($provider)->user()->map([]);
     $socialProvider = SocialProvider::where('social_provider_id', $socialProviderData->id)->where('social_provider_type_id', $socialProviderType->id)->first();
     if (Auth::check()) {
         $user = Auth::user();
         if (!$socialProvider) {
             $socialProvider = new SocialProvider();
             $socialProvider->token = isset($socialProviderData->token) ? $socialProviderData->token : null;
             $socialProvider->social_provider_id = isset($socialProviderData->id) ? $socialProviderData->id : null;
             $socialProvider->token_secret = isset($socialProviderData->tokenSecret) ? $socialProviderData->tokenSecret : '';
             $socialProvider->social_provider_type_id = $socialProviderType->id;
             $socialProvider->nickname = '' + $socialProviderData->nickname;
             $socialProvider->email = $socialProviderData->email;
             $socialProvider->name = $socialProviderData->name;
             $socialProvider->avatar = $socialProviderData->avatar;
             $socialProvider->other_provider_info = \Psy\Util\Json::encode($socialProviderData);
             $socialProvider->save();
             $user->socialProviders()->save($socialProvider);
             Auth::login($user);
         }
     } else {
         if ($socialProvider) {
             Auth::login($socialProvider->user);
         } else {
             $socialProvider = new SocialProvider();
             $socialProvider->token = isset($socialProviderData->token) ? $socialProviderData->token : null;
             $socialProvider->social_provider_id = isset($socialProviderData->id) ? $socialProviderData->id : null;
             $socialProvider->token_secret = isset($socialProviderData->tokenSecret) ? $socialProviderData->tokenSecret : '';
             $socialProvider->social_provider_type_id = $socialProviderType->id;
             $socialProvider->nickname = '' + $socialProviderData->nickname;
             $socialProvider->email = $socialProviderData->email;
             $socialProvider->name = $socialProviderData->name;
             $socialProvider->avatar = $socialProviderData->avatar;
             $socialProvider->other_provider_info = \Psy\Util\Json::encode($socialProviderData);
             $socialProvider->save();
             $user = User::firstOrNew(['email' => $socialProvider->email]);
             $user->name = isset($user->name) ? $user->name : $socialProvider->name;
             $user->username = null;
             $user->password = null;
             $user->email = isset($user->email) ? $user->email : $socialProvider->email;
             $user->avatar = isset($user->avatar) ? $user->avatar : $socialProvider->avatar;
             $user->save();
             $user->socialProviders()->save($socialProvider);
             Auth::login($user);
         }
     }
 }
开发者ID:kursat,项目名称:liosta,代码行数:49,代码来源:UserController.php

示例15: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $credentials = ['email' => $this->argument('email')];
     $user = User::firstOrNew($credentials);
     if (!$user->isDirty()) {
         $this->info('User already exists');
         return;
     }
     $user->name = $this->argument('name');
     $user->rights = $this->option('admin') ? ['admin'] : [];
     $user->save();
     \Password::sendResetLink($credentials, function (Message $message) {
         $message->subject('Velkommen til ub-baser');
     });
     $this->info('User created, email sent to ' . $user->email . '.');
 }
开发者ID:scriptotek,项目名称:ub-baser,代码行数:21,代码来源:CreateUserCommand.php


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