public function generateToken($save = false)
    {
        $attributes = [
            'token'      => str_random(16),
            'is_used'    => false,
            'user_id'    => $this->id,
            'created_at' => time()
        ];

        $token = App::make(Token::class);
        $token->fill($attributes);
        if ($save) {
            $token->save();
        }

        return $token;
    }
public function generateToken($save = false)
    {
        $attributes = [
            'token'      => str_random(16),
            'is_used'    => false,
            'user_id'    => $this->id,
            'created_at' => time()
        ];

        $token = App::make(Token::class);
        $token->fill($attributes);
        if ($save) {
            $token->save();
        }

        return $token;
    }
public function generateToken ( $ save = false ) { $ attributes = [ 'token' => str_random ( 16 ) , 'is_used' => false , 'user_id' => $ this -> id , 'created_at' => time ( ) ] ; $ token = App :: make ( Token :: class ) ; $ token -> fill ( $ attributes ) ; if ( $ save ) { $ token -> save ( ) ; } return $ token ; }
Generate a token for the current user.

@param bool $save Generate token and save it.

@return Token
Generate a token for the current user .