| 1 | <?php |
||
| 2 | |||
| 3 | namespace Spinen\QuickBooks\Providers; |
||
| 4 | |||
| 5 | use Illuminate\Contracts\Foundation\Application; |
||
| 6 | use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
||
| 7 | use Spinen\QuickBooks\Client; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class ClientServiceProvider |
||
| 11 | * |
||
| 12 | * @package Spinen\QuickBooks |
||
| 13 | */ |
||
| 14 | class ClientServiceProvider extends LaravelServiceProvider |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Indicates if loading of the provider is deferred. |
||
| 18 | * |
||
| 19 | * @var bool |
||
| 20 | */ |
||
| 21 | protected $defer = true; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Get the services provided by the provider. |
||
| 25 | * |
||
| 26 | * @return array |
||
| 27 | */ |
||
| 28 | public function provides() |
||
| 29 | { |
||
| 30 | return [ |
||
| 31 | Client::class, |
||
| 32 | ]; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Register the application services. |
||
| 37 | * |
||
| 38 | * @return void |
||
| 39 | */ |
||
| 40 | public function register() |
||
| 41 | { |
||
| 42 | $this->app->bind(Client::class, function (Application $app) { |
||
| 43 | $token = ($app->auth->user()->quickBooksToken) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 44 | ? : $app->auth->user() |
||
| 45 | ->quickBooksToken() |
||
| 46 | ->make(); |
||
| 47 | |||
| 48 | return new Client($app->config->get('quickbooks'), $token); |
||
|
0 ignored issues
–
show
|
|||
| 49 | }); |
||
| 50 | |||
| 51 | $this->app->alias(Client::class, 'QuickBooks'); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |