2019-08-23 02:32:49 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
use App\Contracts\AirportLookup;
|
|
|
|
use App\Contracts\Metar;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
2019-09-06 04:55:51 +08:00
|
|
|
use VaCentral\Contracts\IVaCentral;
|
|
|
|
use VaCentral\VaCentral;
|
2019-08-23 02:32:49 +08:00
|
|
|
|
|
|
|
class BindServiceProviders extends ServiceProvider
|
|
|
|
{
|
|
|
|
public function boot(): void
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Bind the class used to fullfill the Metar class contract
|
|
|
|
*/
|
|
|
|
$this->app->bind(
|
|
|
|
Metar::class,
|
|
|
|
config('phpvms.metar_lookup')
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bind the class used to fullfill the AirportLookup class contract
|
|
|
|
*/
|
|
|
|
$this->app->bind(
|
|
|
|
AirportLookup::class,
|
|
|
|
config('phpvms.airport_lookup')
|
|
|
|
);
|
2019-09-06 04:55:51 +08:00
|
|
|
|
|
|
|
$this->app->bind(
|
|
|
|
IVaCentral::class,
|
|
|
|
function ($app) {
|
|
|
|
$client = new VaCentral();
|
|
|
|
$client->setVaCentralUrl(config('vacentral.api_url'));
|
|
|
|
|
|
|
|
// Set API if exists
|
|
|
|
if (filled(config('vacentral.api_key'))) {
|
|
|
|
$client->setApiKey(config('vacentral.api_key'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $client;
|
|
|
|
}
|
|
|
|
);
|
2019-08-23 02:32:49 +08:00
|
|
|
}
|
|
|
|
}
|