PHP code example of namelivia / laravel-travelperk

1. Go to this page and download the library: Download namelivia/laravel-travelperk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

namelivia / laravel-travelperk example snippets


Namelivia\TravelPerk\Laravel\TravelPerkServiceProvider::class

'TravelPerk' => Namelivia\TravelPerk\Laravel\Facades\TravelPerk::class

use Namelivia\TravelPerk\Laravel\OAuthRedirectionTrait;

use OAuthRedirectionTrait;

return parent::render($request, $exception);

return OAuthRedirectionTrait::handleOAuthRedirection($exception) ?: parent::render($request, $exception);

// You can alias this in config/app.php.
use Namelivia\TravelPerk\Laravel\Facades\TravelPerk;

TravelPerk::expenses()->invoices()->all();
// We're done here - how easy was that, it just works!

use Namelivia\TravelPerk\Laravel\Facades\TravelPerk;

// Writing this…
TravelPerk::connection('main')->expenses()->invoices()->all();

// …is identical to writing this
TravelPerk::expenses()->invoices()->all();

// and is also identical to writing this.
TravelPerk::connection()->expenses()->invoices()->all();

// This is because the main connection is configured to be the default.
TravelPerk::getDefaultConnection(); // This will return main.

// We can change the default connection.
TravelPerk::setDefaultConnection('alternative'); // The default is now alternative.

use Namelivia\TravelPerk\Laravel\TravelPerkManager;

class Foo
{
    protected $travelperk;

    public function __construct(TravelPerkManager $travelperk)
    {
        $this->travelperk = $travelperk;
    }

    public function bar()
    {
        $this->travelperk->expenses()->invoices()->all();
    }
}

App::make('Foo')->bar();
bash
$ php artisan vendor:publish --provider="Namelivia\TravelPerk\Laravel\TravelPerkServiceProvider"