Sorting the dropdown list by name.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Matt Burchett 2021-04-08 08:39:57 -07:00
parent 613bae96eb
commit 589bf47eff

View File

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\EliteShips; use App\Models\EliteShips;
use App\Models\Ships; use App\Models\Ships;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -14,7 +15,12 @@ class ShipsController extends Controller
public function index(){ public function index(){
$ships = \App\Models\Ships::sortable()->paginate(10); $ships = \App\Models\Ships::sortable()->paginate(10);
$eliteShips = EliteShips::all(); $eliteShips = EliteShips::all();
return view('ships.index', ['ships'=>$ships,'eliteShips'=>$eliteShips]); $sortedEliteShips = Arr::sort($eliteShips, function($eliteShip)
{
// Sort ships by their name.
return $eliteShip->shipName;
});
return view('ships.index', ['ships'=>$ships,'eliteShips'=>$sortedEliteShips]);
} }
public function add(Request $request){ public function add(Request $request){