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

@@ -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