本文整理汇总了PHP中App\Repositories\UserRepository::findOrCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::findOrCreate方法的具体用法?PHP UserRepository::findOrCreate怎么用?PHP UserRepository::findOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Repositories\UserRepository
的用法示例。
在下文中一共展示了UserRepository::findOrCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param boolean $hasCode
* @param AuthenticateUserListener $listener
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function execute($provider, $hasCode, AuthenticateUserListener $listener)
{
if (!$hasCode) {
return $this->getAuthorizationFirst($provider);
}
$user = $this->users->findOrCreate($this->getUser($provider));
if ($user === null) {
return $this->getAuthorizationFirst($provider);
}
$this->auth->login($user, true);
return $listener->userHasLoggedIn($user);
}
示例2: execute
/**
* @param boolean $hasCode
* @param AuthenticateUserListener $listener
* @param $type
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function execute($hasCode, AuthenticateUserListener $listener, $type)
{
if (!$hasCode) {
return $this->getAuthorizationFirst();
}
$linkedInData = $this->getLinkedinUser();
$user = $this->users->findOrCreate($linkedInData, $type);
$this->auth->login($user, true);
$user->authType = 'linkedin';
$user->save();
if (is_null($user->profile)) {
$name = explode(' ', $linkedInData->name);
$profile = new Profile(['first_name' => head($name), 'last_name' => last($name)]);
$user->profile()->save($profile);
}
return $listener->userHasLoggedIn($user);
}
示例3: addAdvertisementInvite
public function addAdvertisementInvite(AdvertisementRequest $request, User $user, Company $company, Advertisement $advertisement, Picture $picture)
{
$this->valid_image($request->images);
$images = ImageManagement::upload_image($request->file('images'));
$newUser = $user->findOrCreate($request);
if ($request->user_type) {
$newCompany = $company->create($request, $newUser->id);
$newUser = $newCompany->company()->associate($newUser);
}
$newAdvertisement = $advertisement->create($request);
$newAdvertisement->user()->associate($newUser);
$newAdvertisement = $advertisement->associateIdType($request['ads_type'], $newAdvertisement);
$newAdvertisement = $advertisement->associateIdCategory($request['category'], $newAdvertisement);
$newAdvertisement = $advertisement->associateIdCity($request['id_city'], $newAdvertisement);
foreach ($images as $value) {
$newAdvertisement->picture[] = $picture->create($value);
}
Session::put('advertisement', $newAdvertisement);
return Redirect::route('advertisement.invite.validation');
}