refactor(airport): delete AirportRepository
- Frontend/AirportController: drop airportRepo, use
Airport::with('files')->find($id) ($id was already uppercased
earlier in the method)
- Frontend/PirepController: drop airportRepo from constructor
(only reference was a commented-out selectBoxList call). Phase
2 precedent (Aircraft was the same case).
- Filament/Actions/ExportAction: AIRPORT case uses Airport::all()
- Delete app/Repositories/AirportRepository.php (dead selectBoxList
goes with it)
- phpstan.neon: suppress larastan.relationExistence for
FilesTrait::files() across Aircraft/Airline/Airport/Subfleet.
The morphMany is trait-defined and works at runtime, but
larastan can't statically resolve trait-declared polymorphic
relations. First direct Eloquent with('files') call lands in
this commit, hence the new suppression.
Final commit of Phase 3. AirportRepository is gone; 9 repositories
remain (was 10 at branch start). First Query class
(AirportSearchQuery) and search Form Request (SearchAirportsRequest)
are now in production, ready to be reused by Phases 4/6/7.
This commit is contained in:
parent
096e647932
commit
235cdb13f3
@ -3,10 +3,10 @@
|
||||
namespace App\Filament\Actions;
|
||||
|
||||
use App\Models\Aircraft;
|
||||
use App\Models\Airport;
|
||||
use App\Models\Enums\ImportExportType;
|
||||
use App\Models\Fare;
|
||||
use App\Models\Subfleet;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\ExpenseRepository;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\ExportService;
|
||||
@ -48,7 +48,7 @@ class ExportAction extends Action
|
||||
$path = $exportSvc->exportAircraft($data);
|
||||
break;
|
||||
case ImportExportType::AIRPORT:
|
||||
$data = app(AirportRepository::class)->all();
|
||||
$data = Airport::all();
|
||||
$path = $exportSvc->exportAirports($data);
|
||||
break;
|
||||
case ImportExportType::EXPENSES:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Models\Airport;
|
||||
use App\Repositories\FlightRepository;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@ -13,7 +13,6 @@ use Laracasts\Flash\Flash;
|
||||
class AirportController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AirportRepository $airportRepo,
|
||||
private readonly FlightRepository $flightRepo
|
||||
) {}
|
||||
|
||||
@ -36,7 +35,7 @@ class AirportController extends Controller
|
||||
},
|
||||
];
|
||||
|
||||
$airport = $this->airportRepo->with('files')->where('id', $id)->first();
|
||||
$airport = Airport::with('files')->find($id);
|
||||
if (!$airport) {
|
||||
Flash::error('Airport not found!');
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@ use App\Models\PirepField;
|
||||
use App\Models\SimBrief;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
@ -44,7 +43,6 @@ class PirepController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AirlineRepository $airlineRepo,
|
||||
private readonly AirportRepository $airportRepo,
|
||||
private readonly FareService $fareSvc,
|
||||
private readonly FlightRepository $flightRepo,
|
||||
private readonly GeoService $geoSvc,
|
||||
@ -289,7 +287,7 @@ class PirepController extends Controller
|
||||
'read_only' => false,
|
||||
'airline_list' => $this->airlineRepo->selectBoxList(true),
|
||||
'aircraft_list' => $aircraft_list,
|
||||
'airport_list' => [], // $this->airportRepo->selectBoxList(true),
|
||||
'airport_list' => [],
|
||||
'pirep_fields' => PirepField::whereIn('pirep_source', [$pirep_source, PirepFieldSource::BOTH])->get(),
|
||||
'field_values' => [],
|
||||
'fare_values' => $fare_values,
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Contracts\Repository;
|
||||
use App\Models\Airport;
|
||||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
use Prettus\Repository\Traits\CacheableRepository;
|
||||
|
||||
class AirportRepository extends Repository implements CacheableInterface
|
||||
{
|
||||
use CacheableRepository;
|
||||
|
||||
protected $fieldSearchable = [
|
||||
'iata' => 'like',
|
||||
'icao' => 'like',
|
||||
'name' => 'like',
|
||||
];
|
||||
|
||||
public function model()
|
||||
{
|
||||
return Airport::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of airports formatted for a select box
|
||||
*
|
||||
* @param bool $add_blank
|
||||
* @param bool $only_hubs
|
||||
*/
|
||||
public function selectBoxList($add_blank = false, $only_hubs = false): array
|
||||
{
|
||||
$retval = [];
|
||||
$where = [];
|
||||
|
||||
if ($only_hubs) {
|
||||
$where['hub'] = 1;
|
||||
}
|
||||
|
||||
$items = $this->orderBy('icao', 'asc')->findWhere($where);
|
||||
|
||||
if ($add_blank) {
|
||||
$retval[''] = '';
|
||||
}
|
||||
|
||||
foreach ($items as $i) {
|
||||
$s = $i->icao.' - '.$i->name;
|
||||
if (!$only_hubs && $i->hub) {
|
||||
$s .= ' (hub)';
|
||||
}
|
||||
|
||||
$retval[$i->icao] = $s;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,12 @@ parameters:
|
||||
|
||||
# Eloquent Builder methods are not documented on repositories
|
||||
- '#Call to an undefined method App\\Repositories\\[a-zA-Z]+Repository::[a-zA-Z]+\(\)#'
|
||||
|
||||
# FilesTrait::files() defines a morphMany via traits — larastan's relationExistence
|
||||
# rule can't statically resolve trait-defined polymorphic relations even though they
|
||||
# work at runtime. Models using FilesTrait: Aircraft, Airline, Airport, Subfleet.
|
||||
- identifier: larastan.relationExistence
|
||||
message: '#Relation ''files'' is not found in App\\Models\\(Aircraft|Airline|Airport|Subfleet) model\.#'
|
||||
# - '#PHPDoc tag @var#'
|
||||
#
|
||||
# excludePaths:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user