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


PHP Social::where方法代码示例

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


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

示例1: Callback

 /**
  * Obtain the user information from the social media site.
  *
  * @return Response
  */
 public function Callback($provider)
 {
     $user = Socialite::driver($provider)->user();
     $socialUser = null;
     //Check is this email present
     $userCheck = User::where('email', '=', $user->email)->first();
     if (!empty($userCheck)) {
         $socialUser = $userCheck;
     } else {
         $sameSocialId = Social::where('social_id', '=', $user->id)->where('provider', '=', $provider)->first();
         if (empty($sameSocialId)) {
             //There is no combination of this social id and provider, so create new one
             $name = explode(' ', $user->name);
             $data = ['first_name' => $name[0], 'last_name' => $name[1], 'email' => $email];
             $this->userRepository->SocialRegister($newSocialUser);
             $socialData['social_id'] = $user->id;
             $socialData['provider'] = $provider;
             $socialRepository->saveSocial($socialData);
             $role = Role::whereName('user')->first();
             $newSocialUser->assignRole($role);
             $socialUser = $newSocialUser;
         } else {
             //Load this existing social user
             $socialUser = $sameSocialId->user;
         }
     }
     $this->auth->login($socialUser, true);
     if ($this->auth->user()->hasRole('user')) {
         $this->checkFutureList();
         return redirect('check');
     }
     if ($this->auth->user()->hasRole('administrator')) {
         return redirect('adminHome');
     }
 }
开发者ID:Timmerdev,项目名称:timmer_app,代码行数:40,代码来源:AuthController.php

示例2: getSocialHandle

 public function getSocialHandle($provider)
 {
     $user = Socialite::with($provider)->user();
     $socialUser = null;
     //Check is this email present
     $userCheck = User::where('email', '=', $user->email)->first();
     if (!empty($userCheck)) {
         $socialUser = $userCheck;
     } else {
         $sameSocialId = Social::where('social_id', '=', $user->id)->where('provider', '=', $provider)->first();
         if (empty($sameSocialId)) {
             //There is no combination of this social id and provider, so create new one
             $newSocialUser = new User();
             $newSocialUser->email = $user->email;
             $name = explode(' ', $user->name);
             $newSocialUser->first_name = $name[0];
             $newSocialUser->last_name = $name[1];
             $newSocialUser->save();
             $socialData = new Social();
             $socialData->social_id = $user->id;
             $socialData->provider = $provider;
             $newSocialUser->social()->save($socialData);
             // Add role
             $role = Role::whereName('user')->first();
             $newSocialUser->assignRole($role);
             $socialUser = $newSocialUser;
         } else {
             //Load this existing social user
             $socialUser = $sameSocialId->user;
         }
     }
     $this->auth->login($socialUser, true);
     if ($this->auth->user()->hasRole('user')) {
         return redirect()->route('/');
     }
     if ($this->auth->user()->hasRole('administrator')) {
         return redirect()->route('/backoffice');
     }
     return \App::abort(500);
 }
开发者ID:zekaroz,项目名称:Opel,代码行数:40,代码来源:AuthController.php


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