User can add/edit flights
This commit is contained in:
@@ -25,6 +25,9 @@ class LogoController extends Controller
|
||||
$airline = Airline::where('id', $id)
|
||||
->first();
|
||||
|
||||
//Blank Airline Logo
|
||||
if(!$airline) return $this->getLogoByCode('2H');
|
||||
|
||||
return $this->getAirlineLogo($airline);
|
||||
}
|
||||
|
||||
@@ -49,4 +52,74 @@ class LogoController extends Controller
|
||||
|
||||
return $this->getAirlineLogo($airline);
|
||||
}
|
||||
|
||||
|
||||
public static function deduplicateLogo(string $logo, array $correctInternalNames)
|
||||
{
|
||||
$log = fn(string $message) => print($message . PHP_EOL);
|
||||
|
||||
if (empty($correctInternalNames)) {
|
||||
$nulled = Airline::where('logo', $logo)->get(['name', 'internal_name']);
|
||||
Airline::where('logo', $logo)->update(['logo' => null]);
|
||||
foreach ($nulled as $airline) {
|
||||
$log(" Logo nulled: {$airline->name} ({$airline->internal_name})");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$nulled = Airline::where('logo', $logo)
|
||||
->whereNotIn('internal_name', $correctInternalNames)
|
||||
->get(['name', 'internal_name']);
|
||||
|
||||
Airline::where('logo', $logo)
|
||||
->whereNotIn('internal_name', $correctInternalNames)
|
||||
->update(['logo' => null]);
|
||||
|
||||
foreach ($nulled as $airline) {
|
||||
$log(" Logo nulled: {$airline->name} ({$airline->internal_name})");
|
||||
}
|
||||
}
|
||||
|
||||
public static function nullMissingLogoFiles()
|
||||
{
|
||||
$log = fn(string $message) => print($message . PHP_EOL);
|
||||
|
||||
$airlines = Airline::whereNotNull('logo')->get(['id', 'name', 'logo']);
|
||||
|
||||
foreach ($airlines as $airline) {
|
||||
$path = storage_path('app/private/images/logos/tail/' . $airline->logo);
|
||||
|
||||
if (!file_exists($path)) {
|
||||
$airline->update(['logo' => null]);
|
||||
$log(" Logo nulled (file missing): {$airline->name} — {$airline->logo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function renameLogoFiles()
|
||||
{
|
||||
$log = fn(string $message) => print($message . PHP_EOL);
|
||||
|
||||
$airlines = Airline::whereNotNull('logo')->get(['id', 'name', 'internal_name', 'logo']);
|
||||
|
||||
foreach ($airlines as $airline) {
|
||||
$expectedName = $airline->internal_name . '.png';
|
||||
|
||||
if ($airline->logo === $expectedName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$oldPath = storage_path('app/private/images/logos/tail/' . $airline->logo);
|
||||
$newPath = storage_path('app/private/images/logos/tail/' . $expectedName);
|
||||
|
||||
if (!file_exists($oldPath)) {
|
||||
$log(" Skipping (file missing): {$airline->name} — {$airline->logo}");
|
||||
continue;
|
||||
}
|
||||
|
||||
rename($oldPath, $newPath);
|
||||
$airline->update(['logo' => $expectedName]);
|
||||
$log(" Renamed: {$airline->logo} → {$expectedName} ({$airline->name})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user