From 3cc5ca2c321f485176e11b968c31b1ca2c4ad878 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" <74361521+FatihKoz@users.noreply.github.com> Date: Sun, 21 Mar 2021 16:33:04 +0300 Subject: [PATCH] DownloadController Improvements (#1091) * DownloadController Improvements Added multiple airline support to both Aircraft and Subfleet downloads, if the user has more than one active airline downloads will display the airline name before the object name. Also sorted the returned results to have a better look at the blade. * Trying to pass broken UnitTest Please do fix the UnitTest, this pr has nothing to do with units but still being tested with it and failing. --- app/Http/Controllers/Frontend/DownloadController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Frontend/DownloadController.php b/app/Http/Controllers/Frontend/DownloadController.php index dee02731..a20433da 100644 --- a/app/Http/Controllers/Frontend/DownloadController.php +++ b/app/Http/Controllers/Frontend/DownloadController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Frontend; use App\Contracts\Controller; +use App\Models\Airline; use App\Models\File; use Auth; use Flash; @@ -18,6 +19,7 @@ class DownloadController extends Controller */ public function index() { + $airlines = Airline::where('active', 1)->count(); $files = File::orderBy('ref_model', 'asc')->get(); /** @@ -42,10 +44,14 @@ class DownloadController extends Controller $category = explode('\\', $class); $category = end($category); - if ($category == 'Aircraft') { + if ($category == 'Aircraft' && $airlines > 1) { + $group_name = $category.' > '.$obj->subfleet->airline->name.' '.$obj->icao.' '.$obj->registration; + } elseif ($category == 'Aircraft') { $group_name = $category.' > '.$obj->icao.' '.$obj->registration; } elseif ($category == 'Airport') { $group_name = $category.' > '.$obj->icao.' : '.$obj->name.' ('.$obj->country.')'; + } elseif ($category == 'Subfleet' && $airlines > 1) { + $group_name = $category.' > '.$obj->airline->name.' '.$obj->name; } else { $group_name = $category.' > '.$obj->name; } @@ -53,13 +59,15 @@ class DownloadController extends Controller $regrouped_files[$group_name] = $files; } + ksort($regrouped_files, SORT_STRING); + return view('downloads.index', [ 'grouped_files' => $regrouped_files, ]); } /** - * Show the application dashboard. + * Show the application dashboard * * @param string $id *