Cache the api calls to vacentral and make the iata field optional
This commit is contained in:
parent
ddb8a6f5e9
commit
fa4be69774
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,6 +27,7 @@ Homestead.json
|
||||
tmp/
|
||||
|
||||
# intellij files
|
||||
.idea/composerJson.xml
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/dictionaries
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ComposerJsonPluginSettings">
|
||||
<unboundedVersionInspectionSettings>
|
||||
<excludedPackages>
|
||||
<pattern pattern="makinacorpus/php-bloom" />
|
||||
<pattern pattern="nabeel/*" />
|
||||
</excludedPackages>
|
||||
</unboundedVersionInspectionSettings>
|
||||
<customRepositories />
|
||||
</component>
|
||||
</project>
|
@ -6,6 +6,7 @@ use App\Repositories\AirportRepository;
|
||||
use App\Http\Controllers\AppBaseController;
|
||||
use App\Http\Resources\Airport as AirportResource;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use VaCentral\Airport as AirportLookup;
|
||||
|
||||
class AirportController extends AppBaseController
|
||||
@ -25,7 +26,14 @@ class AirportController extends AppBaseController
|
||||
*/
|
||||
public function lookup($id)
|
||||
{
|
||||
$airport = AirportLookup::get($id);
|
||||
$airport = Cache::remember(
|
||||
config('cache.keys.AIRPORT_VACENTRAL_LOOKUP.key') . $id,
|
||||
config('cache.keys.RANKS_PILOT_LIST.time'),
|
||||
function () use ($id) {
|
||||
return AirportLookup::get($id);
|
||||
}
|
||||
);
|
||||
|
||||
return new AirportResource(collect($airport));
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,13 @@ return [
|
||||
'prefix' => env('CACHE_PREFIX', ''),
|
||||
|
||||
'keys' => [
|
||||
'AIRPORT_VACENTRAL_LOOKUP' => [
|
||||
'key' => 'airports:lookup:',
|
||||
'time' => 1800,
|
||||
],
|
||||
'RANKS_PILOT_LIST' => [
|
||||
'key' => 'ranks:pilot_list',
|
||||
'time' => 1440,
|
||||
'time' => 600,
|
||||
]
|
||||
],
|
||||
|
||||
|
@ -16,7 +16,7 @@ class CreateAirportsTable extends Migration
|
||||
Schema::create('airports', function (Blueprint $table) {
|
||||
// $table->bigIncrements('id');
|
||||
$table->string('id', 5)->primary();
|
||||
$table->string('iata', 5);
|
||||
$table->string('iata', 5)->nullable();
|
||||
$table->string('icao', 5);
|
||||
$table->string('name', 100);
|
||||
$table->string('location', 100)->nullable();
|
||||
|
Loading…
Reference in New Issue
Block a user