public function createToken(?Authenticatable $user, ?string $email = null) : Model
    {
        if ($user === null) {
            throw new NullValueException("User cannot be null");
        }

        $email = $email ?? $user->email;

        if ($this->canInsertToken($user, $email)) {
            return $this->insertToken($user, $this->generateToken($this->config->get('app.key')), $email);
        }

        throw new InvalidPermissionException('Cannot create token');
    }
public function createToken(?Authenticatable $user, ?string $email = null) : Model
    {
        if ($user === null) {
            throw new NullValueException("User cannot be null");
        }

        $email = $email ?? $user->email;

        if ($this->canInsertToken($user, $email)) {
            return $this->insertToken($user, $this->generateToken($this->config->get('app.key')), $email);
        }

        throw new InvalidPermissionException('Cannot create token');
    }
public function createToken ( ? Authenticatable $ user , ? string $ email = null ) : Model { if ( $ user === null ) { throw new NullValueException ( "User cannot be null" ) ; } $ email = $ email ?? $ user -> email ; if ( $ this -> canInsertToken ( $ user , $ email ) ) { return $ this -> insertToken ( $ user , $ this -> generateToken ( $ this -> config -> get ( 'app.key' ) ) , $ email ) ; } throw new InvalidPermissionException ( 'Cannot create token' ) ; }
Create and insert token

@param \Illuminate\Contracts\Auth\Authenticatable|User $user
@param null|string                                     $email
@return \Laranix\Support\Database\Model
@throws \Laranix\Support\Exception\InvalidPermissionException
@throws \Laranix\Support\Exception\NullValueException
Create and insert token