Cartalyst\Sentinel\Activations\ActivationRepositoryInterface::create PHP Method

create() public method

Create a new activation record and code.
public create ( Cartalyst\Sentinel\Users\UserInterface $user ) : Cartalyst\Sentinel\Activations\ActivationInterface
$user Cartalyst\Sentinel\Users\UserInterface
return Cartalyst\Sentinel\Activations\ActivationInterface
    public function create(UserInterface $user);

Usage Example

Example #1
0
 /**
  * {@inheritDoc}
  */
 public function register(array $data, $validate = true)
 {
     $this->rules = ['email' => 'required|unique:users', 'password' => 'required|confirmed', 'password_confirmation' => 'required'];
     if ($validate) {
         $this->validate($data);
     }
     if (!config('laraflock.dashboard.activations')) {
         $this->registerAndActivate($data, false);
         return true;
     }
     try {
         $user = $this->sentinel->register($data);
     } catch (QueryException $e) {
         throw new AuthenticationException(trans('dashboard::dashboard.errors.auth.create'));
     }
     if (!$user instanceof EloquentUser) {
         throw new AuthenticationException(trans('dashboard::dashboard.errors.auth.create'));
     }
     if (!isset($data['role'])) {
         $data['role'] = config('laraflock.dashboard.defaultRole');
     }
     if (!($role = $this->sentinel->findRoleBySlug($data['role']))) {
         throw new RolesException(trans('dashboard::dashboard.errors.role.found'));
     }
     $role->users()->attach($user);
     if (!($activation = $this->illuminateActivationRepository->create($user))) {
         throw new AuthenticationException(trans('dashboard::dashboard.errors.auth.activation.create'));
     }
     return $activation;
 }