Cache the api calls to vacentral and make the iata field optional
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -27,6 +27,7 @@ Homestead.json
|
|||||||
tmp/
|
tmp/
|
||||||
|
|
||||||
# intellij files
|
# intellij files
|
||||||
|
.idea/composerJson.xml
|
||||||
.idea/**/workspace.xml
|
.idea/**/workspace.xml
|
||||||
.idea/**/tasks.xml
|
.idea/**/tasks.xml
|
||||||
.idea/dictionaries
|
.idea/dictionaries
|
||||||
|
|||||||
12
.idea/composerJson.xml
generated
12
.idea/composerJson.xml
generated
@@ -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\Controllers\AppBaseController;
|
||||||
use App\Http\Resources\Airport as AirportResource;
|
use App\Http\Resources\Airport as AirportResource;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use VaCentral\Airport as AirportLookup;
|
use VaCentral\Airport as AirportLookup;
|
||||||
|
|
||||||
class AirportController extends AppBaseController
|
class AirportController extends AppBaseController
|
||||||
@@ -25,7 +26,14 @@ class AirportController extends AppBaseController
|
|||||||
*/
|
*/
|
||||||
public function lookup($id)
|
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));
|
return new AirportResource(collect($airport));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ return [
|
|||||||
'prefix' => env('CACHE_PREFIX', ''),
|
'prefix' => env('CACHE_PREFIX', ''),
|
||||||
|
|
||||||
'keys' => [
|
'keys' => [
|
||||||
|
'AIRPORT_VACENTRAL_LOOKUP' => [
|
||||||
|
'key' => 'airports:lookup:',
|
||||||
|
'time' => 1800,
|
||||||
|
],
|
||||||
'RANKS_PILOT_LIST' => [
|
'RANKS_PILOT_LIST' => [
|
||||||
'key' => '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) {
|
Schema::create('airports', function (Blueprint $table) {
|
||||||
// $table->bigIncrements('id');
|
// $table->bigIncrements('id');
|
||||||
$table->string('id', 5)->primary();
|
$table->string('id', 5)->primary();
|
||||||
$table->string('iata', 5);
|
$table->string('iata', 5)->nullable();
|
||||||
$table->string('icao', 5);
|
$table->string('icao', 5);
|
||||||
$table->string('name', 100);
|
$table->string('name', 100);
|
||||||
$table->string('location', 100)->nullable();
|
$table->string('location', 100)->nullable();
|
||||||
|
|||||||
Reference in New Issue
Block a user