Laravel 9 Update (#1413)

Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
This commit is contained in:
Nabeel S
2022-03-14 11:45:18 -04:00
committed by GitHub
parent 00bf18c225
commit 12848091a2
340 changed files with 6130 additions and 4502 deletions

View File

@@ -13,8 +13,8 @@ use Request;
*/
class AirportController extends Controller
{
private $airportRepo;
private $flightRepo;
private AirportRepository $airportRepo;
private FlightRepository $flightRepo;
public function __construct(
AirportRepository $airportRepo,

View File

@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth;
*/
class DashboardController extends Controller
{
private $pirepRepo;
private PirepRepository $pirepRepo;
/**
* DashboardController constructor.

View File

@@ -5,9 +5,12 @@ namespace App\Http\Controllers\Frontend;
use App\Contracts\Controller;
use App\Models\Airline;
use App\Models\File;
use Auth;
use Flash;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Laracasts\Flash\Flash;
use Nwidart\Modules\Exceptions\ModuleNotFoundException;
use Nwidart\Modules\Facades\Module;
/**
* Class DownloadController
@@ -62,6 +65,19 @@ class DownloadController extends Controller
}
}
// See if they inserted a link to the ACARS download
try {
Module::findOrFail('VMSAcars');
$downloadUrl = DB::table('vmsacars_config')->where(['id' => 'download_url'])->first();
if (!empty($downloadUrl) && !empty($downloadUrl->value)) {
$regrouped_files['ACARS'] = collect([
new File(['id' => 'vmsacars', 'name' => 'ACARS Client']),
]);
}
} catch (ModuleNotFoundException) {
// noop, don't insert the ACARS download
}
ksort($regrouped_files, SORT_STRING);
return view('downloads.index', [
@@ -79,12 +95,30 @@ class DownloadController extends Controller
*/
public function show($id)
{
// See if they're trying to download the ACARS client
if ($id === 'vmsacars' && Auth::check()) {
try {
Module::find('VMSAcars');
$downloadUrl = DB::table('vmsacars_config')
->where(['id' => 'download_url'])
->first();
if (!empty($downloadUrl) && !empty($downloadUrl->value)) {
return redirect()->to($downloadUrl->value);
}
} catch (ModuleNotFoundException) {
}
return redirect()->back();
}
/**
* @var File $file
*/
$file = File::find($id);
if (!$file) {
Flash::error('File doesn\'t exist');
return redirect()->back();
}
@@ -98,6 +132,7 @@ class DownloadController extends Controller
if ($file->disk === 'public') {
$storage = Storage::disk('public');
return $storage->download($file->path, $file->filename);
}

View File

@@ -23,13 +23,13 @@ use Prettus\Repository\Exceptions\RepositoryException;
class FlightController extends Controller
{
private $airlineRepo;
private $airportRepo;
private $flightRepo;
private $moduleSvc;
private $subfleetRepo;
private $geoSvc;
private $userRepo;
private AirlineRepository $airlineRepo;
private AirportRepository $airportRepo;
private FlightRepository $flightRepo;
private ModuleService $moduleSvc;
private SubfleetRepository $subfleetRepo;
private GeoService $geoSvc;
private UserRepository $userRepo;
/**
* @param AirlineRepository $airlineRepo

View File

@@ -9,8 +9,8 @@ use Illuminate\Http\Request;
class LiveMapController extends Controller
{
private $acarsRepo;
private $geoSvc;
private AcarsRepository $acarsRepo;
private GeoService $geoSvc;
/**
* AcarsController constructor.

View File

@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth;
class PageController extends Controller
{
private $pageRepo;
private PageRepository $pageRepo;
/**
* @param \App\Repositories\PageRepository $pageRepo

View File

@@ -34,16 +34,16 @@ use Laracasts\Flash\Flash;
class PirepController extends Controller
{
private $aircraftRepo;
private $airlineRepo;
private $fareSvc;
private $flightRepo;
private $geoSvc;
private $pirepRepo;
private $airportRepo;
private $pirepFieldRepo;
private $pirepSvc;
private $userSvc;
private AircraftRepository $aircraftRepo;
private AirlineRepository $airlineRepo;
private FareService $fareSvc;
private FlightRepository $flightRepo;
private GeoService $geoSvc;
private PirepRepository $pirepRepo;
private AirportRepository $airportRepo;
private PirepFieldRepository $pirepFieldRepo;
private PirepService $pirepSvc;
private UserService $userSvc;
/**
* @param AircraftRepository $aircraftRepo
@@ -402,8 +402,8 @@ class PirepController extends Controller
$pirep->flight_time = Time::hoursToMinutes($hours) + $minutes;
// Set the correct fuel units
$pirep->block_fuel = new Fuel((float) $request->input('block_fuel'), setting('units.fuel'));
$pirep->fuel_used = new Fuel((float) $request->input('fuel_used'), setting('units.fuel'));
$pirep->block_fuel = Fuel::make((float) $request->input('block_fuel'), setting('units.fuel'));
$pirep->fuel_used = Fuel::make((float) $request->input('fuel_used'), setting('units.fuel'));
// Put the time that this is currently submitted
$attrs['submitted_at'] = Carbon::now('UTC');

View File

@@ -10,7 +10,6 @@ use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\UserRepository;
use App\Support\Countries;
use App\Support\Discord;
use App\Support\Timezonelist;
use App\Support\Utils;
use Illuminate\Http\Request;
@@ -25,9 +24,9 @@ use Nwidart\Modules\Facades\Module;
class ProfileController extends Controller
{
private $airlineRepo;
private $airportRepo;
private $userRepo;
private AirlineRepository $airlineRepo;
private AirportRepository $airportRepo;
private UserRepository $userRepo;
/**
* ProfileController constructor.
@@ -80,11 +79,21 @@ class ProfileController extends Controller
public function show($id)
{
/** @var \App\Models\User $user */
$with = ['airline', 'awards', 'current_airport', 'fields.field', 'home_airport', 'last_pirep', 'rank', 'typeratings'];
$with = [
'airline',
'awards',
'current_airport',
'fields.field',
'home_airport',
'last_pirep',
'rank',
'typeratings',
];
$user = User::with($with)->where('id', $id)->first();
if (empty($user)) {
Flash::error('User not found!');
return redirect(route('frontend.dashboard.index'));
}
@@ -113,6 +122,7 @@ class ProfileController extends Controller
if (empty($user)) {
Flash::error('User not found!');
return redirect(route('frontend.dashboard.index'));
}
@@ -173,10 +183,6 @@ class ProfileController extends Controller
$req_data['password'] = Hash::make($req_data['password']);
}
if (isset($req_data['avatar']) !== null) {
Storage::delete($user->avatar);
}
// Find out the user's private channel id
/*
// TODO: Uncomment when Discord API functionality is enabled
@@ -188,9 +194,13 @@ class ProfileController extends Controller
}*/
if ($request->hasFile('avatar')) {
if ($user->avatar !== null) {
Storage::delete($user->avatar);
}
$avatar = $request->file('avatar');
$file_name = $user->ident.'.'.$avatar->getClientOriginalExtension();
$path = "avatars/{$file_name}";
$path = "avatars/$file_name";
// Create the avatar, resizing it and keeping the aspect ratio.
// https://stackoverflow.com/a/26892028

View File

@@ -24,11 +24,11 @@ use Illuminate\Support\Facades\Auth;
class SimBriefController
{
private $fareSvc;
private $flightRepo;
private $moduleSvc;
private $simBriefSvc;
private $userSvc;
private FareService $fareSvc;
private FlightRepository $flightRepo;
private ModuleService $moduleSvc;
private SimBriefService $simBriefSvc;
private UserService $userSvc;
public function __construct(
FareService $fareSvc,

View File

@@ -13,7 +13,7 @@ use Prettus\Repository\Exceptions\RepositoryException;
class UserController extends Controller
{
private $userRepo;
private UserRepository $userRepo;
/**
* @param UserRepository $userRepo