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:
@@ -22,9 +22,9 @@ class AircraftController extends Controller
|
||||
{
|
||||
use Importable;
|
||||
|
||||
private $aircraftRepo;
|
||||
private $airportRepo;
|
||||
private $importSvc;
|
||||
private AircraftRepository $aircraftRepo;
|
||||
private AirportRepository $airportRepo;
|
||||
private ImportService $importSvc;
|
||||
|
||||
/**
|
||||
* AircraftController constructor.
|
||||
|
||||
@@ -15,8 +15,8 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class AirlinesController extends Controller
|
||||
{
|
||||
private $airlineRepo;
|
||||
private $airlineSvc;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private AirlineService $airlineSvc;
|
||||
|
||||
/**
|
||||
* AirlinesController constructor.
|
||||
|
||||
@@ -21,8 +21,8 @@ class AirportController extends Controller
|
||||
{
|
||||
use Importable;
|
||||
|
||||
private $airportRepo;
|
||||
private $importSvc;
|
||||
private AirportRepository $airportRepo;
|
||||
private ImportService $importSvc;
|
||||
|
||||
/**
|
||||
* @param AirportRepository $airportRepo
|
||||
|
||||
@@ -14,8 +14,8 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
class AwardController extends Controller
|
||||
{
|
||||
/** @var AwardRepository */
|
||||
private $awardRepository;
|
||||
private $awardSvc;
|
||||
private AwardRepository $awardRepository;
|
||||
private AwardService $awardSvc;
|
||||
|
||||
/**
|
||||
* AwardController constructor.
|
||||
|
||||
@@ -16,12 +16,12 @@ use Laracasts\Flash\Flash;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
private $cronSvc;
|
||||
private $kvpRepo;
|
||||
private $newsRepo;
|
||||
private $newsSvc;
|
||||
private $pirepRepo;
|
||||
private $userRepo;
|
||||
private CronService $cronSvc;
|
||||
private KvpRepository $kvpRepo;
|
||||
private NewsRepository $newsRepo;
|
||||
private NewsService $newsSvc;
|
||||
private PirepRepository $pirepRepo;
|
||||
private UserRepository $userRepo;
|
||||
|
||||
/**
|
||||
* DashboardController constructor.
|
||||
|
||||
@@ -20,9 +20,9 @@ class ExpenseController extends Controller
|
||||
{
|
||||
use Importable;
|
||||
|
||||
private $airlineRepo;
|
||||
private $expenseRepo;
|
||||
private $importSvc;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private ExpenseRepository $expenseRepo;
|
||||
private ImportService $importSvc;
|
||||
|
||||
/**
|
||||
* expensesController constructor.
|
||||
|
||||
@@ -20,8 +20,8 @@ class FareController extends Controller
|
||||
{
|
||||
use Importable;
|
||||
|
||||
private $fareRepo;
|
||||
private $importSvc;
|
||||
private FareRepository $fareRepo;
|
||||
private ImportService $importSvc;
|
||||
|
||||
/**
|
||||
* FareController constructor.
|
||||
|
||||
@@ -12,7 +12,7 @@ use Laracasts\Flash\Flash;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
private $fileSvc;
|
||||
private FileService $fileSvc;
|
||||
|
||||
public function __construct(FileService $fileSvc)
|
||||
{
|
||||
|
||||
@@ -12,8 +12,8 @@ use Illuminate\Http\Request;
|
||||
|
||||
class FinanceController extends Controller
|
||||
{
|
||||
private $airlineRepo;
|
||||
private $financeSvc;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private FinanceService $financeSvc;
|
||||
|
||||
/**
|
||||
* @param AirlineRepository $airlineRepo
|
||||
|
||||
@@ -31,15 +31,15 @@ class FlightController extends Controller
|
||||
{
|
||||
use Importable;
|
||||
|
||||
private $airlineRepo;
|
||||
private $airportRepo;
|
||||
private $fareRepo;
|
||||
private $flightRepo;
|
||||
private $flightFieldRepo;
|
||||
private $fareSvc;
|
||||
private $flightSvc;
|
||||
private $importSvc;
|
||||
private $subfleetRepo;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private AirportRepository $airportRepo;
|
||||
private FareRepository $fareRepo;
|
||||
private FlightRepository $flightRepo;
|
||||
private FlightFieldRepository $flightFieldRepo;
|
||||
private FareService $fareSvc;
|
||||
private FlightService $flightSvc;
|
||||
private ImportService $importSvc;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
|
||||
/**
|
||||
* FlightController constructor.
|
||||
|
||||
@@ -10,7 +10,7 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class FlightFieldController extends Controller
|
||||
{
|
||||
private $flightFieldRepo;
|
||||
private FlightFieldRepository $flightFieldRepo;
|
||||
|
||||
/**
|
||||
* FlightFieldController constructor.
|
||||
|
||||
@@ -14,9 +14,9 @@ use Laracasts\Flash\Flash;
|
||||
|
||||
class MaintenanceController extends Controller
|
||||
{
|
||||
private $cronSvc;
|
||||
private $kvpRepo;
|
||||
private $versionSvc;
|
||||
private CronService $cronSvc;
|
||||
private KvpRepository $kvpRepo;
|
||||
private VersionService $versionSvc;
|
||||
|
||||
public function __construct(
|
||||
CronService $cronSvc,
|
||||
|
||||
@@ -14,7 +14,7 @@ use Illuminate\View\View;
|
||||
|
||||
class ModulesController extends Controller
|
||||
{
|
||||
private $moduleSvc;
|
||||
private ModuleService $moduleSvc;
|
||||
|
||||
public function __construct(ModuleService $moduleSvc)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ use Laracasts\Flash\Flash;
|
||||
|
||||
class PagesController extends Controller
|
||||
{
|
||||
private $pageRepo;
|
||||
private PageRepository $pageRepo;
|
||||
|
||||
/**
|
||||
* @param PageRepository $pageRepo
|
||||
|
||||
@@ -29,16 +29,16 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $airportRepo;
|
||||
private $airlineRepo;
|
||||
private $aircraftRepo;
|
||||
private $fareSvc;
|
||||
private $journalRepo;
|
||||
private $pirepSvc;
|
||||
private $pirepRepo;
|
||||
private $pirepFieldRepo;
|
||||
private $subfleetRepo;
|
||||
private $userSvc;
|
||||
private AirportRepository $airportRepo;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private AircraftRepository $aircraftRepo;
|
||||
private FareService $fareSvc;
|
||||
private JournalRepository $journalRepo;
|
||||
private PirepService $pirepSvc;
|
||||
private PirepRepository $pirepRepo;
|
||||
private PirepFieldRepository $pirepFieldRepo;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
private UserService $userSvc;
|
||||
|
||||
/**
|
||||
* PirepController constructor.
|
||||
|
||||
@@ -12,7 +12,7 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class PirepFieldController extends Controller
|
||||
{
|
||||
private $pirepFieldRepo;
|
||||
private PirepFieldRepository $pirepFieldRepo;
|
||||
|
||||
/**
|
||||
* PirepFieldController constructor.
|
||||
|
||||
@@ -15,9 +15,9 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class RankController extends Controller
|
||||
{
|
||||
private $fleetSvc;
|
||||
private $rankRepository;
|
||||
private $subfleetRepo;
|
||||
private FleetService $fleetSvc;
|
||||
private RankRepository $rankRepository;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
|
||||
/**
|
||||
* RankController constructor.
|
||||
|
||||
@@ -15,9 +15,9 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class RolesController extends Controller
|
||||
{
|
||||
private $permsRepo;
|
||||
private $rolesRepo;
|
||||
private $roleSvc;
|
||||
private PermissionsRepository $permsRepo;
|
||||
private RoleRepository $rolesRepo;
|
||||
private RoleService $roleSvc;
|
||||
|
||||
/**
|
||||
* AirlinesController constructor.
|
||||
|
||||
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
private $financeSvc;
|
||||
private FinanceService $financeSvc;
|
||||
|
||||
/**
|
||||
* @param FinanceService $financeSvc
|
||||
|
||||
@@ -30,14 +30,14 @@ class SubfleetController extends Controller
|
||||
{
|
||||
use Importable;
|
||||
|
||||
private $aircraftRepo;
|
||||
private $fareRepo;
|
||||
private $fareSvc;
|
||||
private $fleetSvc;
|
||||
private $importSvc;
|
||||
private $rankRepo;
|
||||
private $subfleetRepo;
|
||||
private $typeratingRepo;
|
||||
private AircraftRepository $aircraftRepo;
|
||||
private FareRepository $fareRepo;
|
||||
private FareService $fareSvc;
|
||||
private FleetService $fleetSvc;
|
||||
private ImportService $importSvc;
|
||||
private RankRepository $rankRepo;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
private TypeRatingRepository $typeratingRepo;
|
||||
|
||||
/**
|
||||
* SubfleetController constructor.
|
||||
|
||||
@@ -15,9 +15,9 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class TypeRatingController extends Controller
|
||||
{
|
||||
private $fleetSvc;
|
||||
private $subfleetRepo;
|
||||
private $typeratingRepo;
|
||||
private FleetService $fleetSvc;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
private TypeRatingRepository $typeratingRepo;
|
||||
|
||||
public function __construct(
|
||||
FleetService $fleetSvc,
|
||||
|
||||
@@ -27,13 +27,13 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
private $airlineRepo;
|
||||
private $airportRepo;
|
||||
private $pirepRepo;
|
||||
private $roleRepo;
|
||||
private $typeratingRepo;
|
||||
private $userRepo;
|
||||
private $userSvc;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private AirportRepository $airportRepo;
|
||||
private PirepRepository $pirepRepo;
|
||||
private RoleRepository $roleRepo;
|
||||
private TypeRatingRepository $typeratingRepo;
|
||||
private UserRepository $userRepo;
|
||||
private UserService $userSvc;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
|
||||
@@ -11,7 +11,7 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
class UserFieldController extends Controller
|
||||
{
|
||||
/** @var \App\Repositories\UserFieldRepository */
|
||||
private $userFieldRepo;
|
||||
private UserFieldRepository $userFieldRepo;
|
||||
|
||||
/**
|
||||
* @param UserFieldRepository $userFieldRepo
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
||||
use App\Contracts\Controller;
|
||||
use App\Events\AcarsUpdate;
|
||||
use App\Exceptions\PirepCancelled;
|
||||
use App\Exceptions\PirepNotFound;
|
||||
use App\Http\Requests\Acars\EventRequest;
|
||||
use App\Http\Requests\Acars\LogRequest;
|
||||
use App\Http\Requests\Acars\PositionRequest;
|
||||
@@ -12,7 +13,6 @@ use App\Http\Resources\AcarsRoute as AcarsRouteResource;
|
||||
use App\Http\Resources\Pirep as PirepResource;
|
||||
use App\Models\Acars;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Models\Pirep;
|
||||
use App\Repositories\AcarsRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
@@ -20,14 +20,13 @@ use App\Services\GeoService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AcarsController extends Controller
|
||||
{
|
||||
private $acarsRepo;
|
||||
private $geoSvc;
|
||||
private $pirepRepo;
|
||||
private AcarsRepository $acarsRepo;
|
||||
private GeoService $geoSvc;
|
||||
private PirepRepository $pirepRepo;
|
||||
|
||||
/**
|
||||
* AcarsController constructor.
|
||||
@@ -67,9 +66,11 @@ class AcarsController extends Controller
|
||||
*/
|
||||
public function live_flights()
|
||||
{
|
||||
$pireps = $this->acarsRepo->getPositions(setting('acars.live_time'))->filter(function ($pirep) {
|
||||
return $pirep->position !== null;
|
||||
});
|
||||
$pireps = $this->acarsRepo->getPositions(setting('acars.live_time'))->filter(
|
||||
function ($pirep) {
|
||||
return $pirep->position !== null;
|
||||
}
|
||||
);
|
||||
|
||||
return PirepResource::collection($pireps);
|
||||
}
|
||||
@@ -102,6 +103,10 @@ class AcarsController extends Controller
|
||||
public function acars_geojson($pirep_id, Request $request)
|
||||
{
|
||||
$pirep = Pirep::find($pirep_id);
|
||||
if (empty($pirep)) {
|
||||
throw new PirepNotFound($pirep_id);
|
||||
}
|
||||
|
||||
$geodata = $this->geoSvc->getFeatureFromAcars($pirep);
|
||||
|
||||
return response()->json([
|
||||
@@ -119,7 +124,11 @@ class AcarsController extends Controller
|
||||
*/
|
||||
public function acars_get($id, Request $request)
|
||||
{
|
||||
$this->pirepRepo->find($id);
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
if (empty($pirep)) {
|
||||
throw new PirepNotFound($id);
|
||||
}
|
||||
|
||||
$acars = Acars::with(['pirep'])
|
||||
->where([
|
||||
'pirep_id' => $id,
|
||||
@@ -137,8 +146,8 @@ class AcarsController extends Controller
|
||||
* @param $id
|
||||
* @param PositionRequest $request
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
@@ -146,6 +155,10 @@ class AcarsController extends Controller
|
||||
{
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
if (empty($pirep)) {
|
||||
throw new PirepNotFound($id);
|
||||
}
|
||||
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
/*Log::debug(
|
||||
@@ -212,8 +225,8 @@ class AcarsController extends Controller
|
||||
* @param $id
|
||||
* @param LogRequest $request
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
@@ -221,6 +234,10 @@ class AcarsController extends Controller
|
||||
{
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
if (empty($pirep)) {
|
||||
throw new PirepNotFound($id);
|
||||
}
|
||||
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
// Log::debug('Posting ACARS log, PIREP: '.$id, $request->post());
|
||||
@@ -266,8 +283,8 @@ class AcarsController extends Controller
|
||||
* @param $id
|
||||
* @param EventRequest $request
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
@@ -275,6 +292,10 @@ class AcarsController extends Controller
|
||||
{
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
if (empty($pirep)) {
|
||||
throw new PirepNotFound($id);
|
||||
}
|
||||
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
Log::debug('Posting ACARS event, PIREP: '.$id, $request->post());
|
||||
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Http\Request;
|
||||
|
||||
class AirlineController extends Controller
|
||||
{
|
||||
private $airlineRepo;
|
||||
private AirlineRepository $airlineRepo;
|
||||
|
||||
/**
|
||||
* AirlineController constructor.
|
||||
|
||||
@@ -15,8 +15,8 @@ use Prettus\Repository\Criteria\RequestCriteria;
|
||||
*/
|
||||
class AirportController extends Controller
|
||||
{
|
||||
private $airportRepo;
|
||||
private $airportSvc;
|
||||
private AirportRepository $airportRepo;
|
||||
private AirportService $airportSvc;
|
||||
|
||||
/**
|
||||
* AirportController constructor.
|
||||
|
||||
@@ -20,14 +20,9 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
class FlightController extends Controller
|
||||
{
|
||||
/** @var \App\Services\FareService */
|
||||
private $fareSvc;
|
||||
|
||||
/** @var \App\Repositories\FlightRepository */
|
||||
private $flightRepo;
|
||||
|
||||
/** @var \App\Services\FlightService */
|
||||
private $flightSvc;
|
||||
private FareService $fareSvc;
|
||||
private FlightRepository $flightRepo;
|
||||
private FlightService $flightSvc;
|
||||
|
||||
/**
|
||||
* @param FareService $fareSvc
|
||||
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Http\Request;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
private $newsRepo;
|
||||
private NewsRepository $newsRepo;
|
||||
|
||||
/**
|
||||
* AirlineController constructor.
|
||||
|
||||
@@ -38,11 +38,11 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $financeSvc;
|
||||
private $journalRepo;
|
||||
private $pirepRepo;
|
||||
private $pirepSvc;
|
||||
private $userSvc;
|
||||
private PirepFinanceService $financeSvc;
|
||||
private JournalRepository $journalRepo;
|
||||
private PirepRepository $pirepRepo;
|
||||
private PirepService $pirepSvc;
|
||||
private UserService $userSvc;
|
||||
|
||||
/**
|
||||
* @param PirepFinanceService $financeSvc
|
||||
|
||||
@@ -12,7 +12,7 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
private $settingRepo;
|
||||
private SettingRepository $settingRepo;
|
||||
|
||||
/**
|
||||
* SettingsController constructor.
|
||||
|
||||
@@ -3,20 +3,27 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use PragmaRX\Version\Package\Facade as Version;
|
||||
use App\Services\VersionService;
|
||||
|
||||
/**
|
||||
* Class StatusController
|
||||
*/
|
||||
class StatusController extends Controller
|
||||
{
|
||||
private VersionService $versionSvc;
|
||||
|
||||
public function __construct(VersionService $versionSvc)
|
||||
{
|
||||
$this->versionSvc = $versionSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
return response()->json([
|
||||
'version' => Version::compact(),
|
||||
'version' => $this->versionSvc->getCurrentVersion(true),
|
||||
'php' => PHP_VERSION,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ use App\Repositories\FlightRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\BidService;
|
||||
use App\Services\FlightService;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -26,17 +25,15 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
private $bidSvc;
|
||||
private $flightRepo;
|
||||
private $flightSvc;
|
||||
private $pirepRepo;
|
||||
private $userRepo;
|
||||
private $userSvc;
|
||||
private BidService $bidSvc;
|
||||
private FlightRepository $flightRepo;
|
||||
private PirepRepository $pirepRepo;
|
||||
private UserRepository $userRepo;
|
||||
private UserService $userSvc;
|
||||
|
||||
/**
|
||||
* @param BidService $bidSvc
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param UserRepository $userRepo
|
||||
* @param UserService $userSvc
|
||||
@@ -44,14 +41,12 @@ class UserController extends Controller
|
||||
public function __construct(
|
||||
BidService $bidSvc,
|
||||
FlightRepository $flightRepo,
|
||||
FlightService $flightSvc,
|
||||
PirepRepository $pirepRepo,
|
||||
UserRepository $userRepo,
|
||||
UserService $userSvc
|
||||
) {
|
||||
$this->bidSvc = $bidSvc;
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->flightSvc = $flightSvc;
|
||||
$this->pirepRepo = $pirepRepo;
|
||||
$this->userRepo = $userRepo;
|
||||
$this->userSvc = $userSvc;
|
||||
|
||||
@@ -16,13 +16,16 @@ class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
|
||||
protected $redirectTo = '/dashboard';
|
||||
/**
|
||||
* Where to redirect after logging in
|
||||
*/
|
||||
protected mixed $redirectTo = '/dashboard';
|
||||
|
||||
/** @var UserService */
|
||||
private $userSvc;
|
||||
private UserService $userSvc;
|
||||
|
||||
/** @var string */
|
||||
private $loginFieldValue;
|
||||
private string $loginFieldValue;
|
||||
|
||||
/**
|
||||
* LoginController constructor.
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Services\UserService;
|
||||
use App\Support\Countries;
|
||||
use App\Support\HttpClient;
|
||||
use App\Support\Timezonelist;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -29,9 +30,10 @@ class RegisterController extends Controller
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
private $airlineRepo;
|
||||
private $airportRepo;
|
||||
private $userService;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private AirportRepository $airportRepo;
|
||||
private HttpClient $httpClient;
|
||||
private UserService $userService;
|
||||
|
||||
/**
|
||||
* RegisterController constructor.
|
||||
@@ -39,18 +41,23 @@ class RegisterController extends Controller
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param UserService $userService
|
||||
* @param HttpClient $httpClient
|
||||
*/
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
AirportRepository $airportRepo,
|
||||
UserService $userService
|
||||
HttpClient $httpClient,
|
||||
UserService $userService,
|
||||
) {
|
||||
$this->airlineRepo = $airlineRepo;
|
||||
$this->airportRepo = $airportRepo;
|
||||
$this->httpClient = $httpClient;
|
||||
$this->userService = $userService;
|
||||
|
||||
$this->middleware('guest');
|
||||
|
||||
$this->redirectTo = config('phpvms.registration_redirect');
|
||||
$this->httpClient = $httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +77,11 @@ class RegisterController extends Controller
|
||||
'countries' => Countries::getSelectList(),
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'userFields' => $userFields,
|
||||
'captcha' => [
|
||||
'enabled' => setting('captcha.enabled', env('CAPTCHA_ENABLED', false)),
|
||||
'site_key' => setting('captcha.site_key', env('CAPTCHA_SITE_KEY')),
|
||||
'secret_key' => setting('captcha.secret_key', env('CAPTCHA_SECRET_KEY')),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -102,8 +114,25 @@ class RegisterController extends Controller
|
||||
$rules['field_'.$field->slug] = 'required';
|
||||
}
|
||||
|
||||
if (config('captcha.enabled')) {
|
||||
$rules['g-recaptcha-response'] = 'required|captcha';
|
||||
/*
|
||||
* Validation for hcaptcha
|
||||
*/
|
||||
$captcha_enabled = setting('captcha.enabled', env('CAPTCHA_ENABLED', false));
|
||||
if ($captcha_enabled === true) {
|
||||
$rules['h-captcha-response'] = [
|
||||
'required',
|
||||
function ($attribute, $value, $fail) {
|
||||
$response = $this->httpClient->form_post('https://hcaptcha.com/siteverify', [
|
||||
'secret' => setting('captcha.secret_key', env('CAPTCHA_SECRET_KEY')),
|
||||
'response' => $value,
|
||||
]);
|
||||
|
||||
if ($response['success'] !== true) {
|
||||
Log::error('Captcha failed '.json_encode($response));
|
||||
$fail('Captcha verification failed, please try again.');
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return Validator::make($data, $rules);
|
||||
@@ -114,8 +143,8 @@ class RegisterController extends Controller
|
||||
*
|
||||
* @param array $opts
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \Exception
|
||||
* @throws \RuntimeException
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
*/
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
private $pirepRepo;
|
||||
private PirepRepository $pirepRepo;
|
||||
|
||||
/**
|
||||
* DashboardController constructor.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,8 +9,8 @@ use Illuminate\Http\Request;
|
||||
|
||||
class LiveMapController extends Controller
|
||||
{
|
||||
private $acarsRepo;
|
||||
private $geoSvc;
|
||||
private AcarsRepository $acarsRepo;
|
||||
private GeoService $geoSvc;
|
||||
|
||||
/**
|
||||
* AcarsController constructor.
|
||||
|
||||
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
private $pageRepo;
|
||||
private PageRepository $pageRepo;
|
||||
|
||||
/**
|
||||
* @param \App\Repositories\PageRepository $pageRepo
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -13,7 +13,7 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
private $userRepo;
|
||||
private UserRepository $userRepo;
|
||||
|
||||
/**
|
||||
* @param UserRepository $userRepo
|
||||
|
||||
@@ -12,8 +12,8 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ImporterController extends Controller
|
||||
{
|
||||
private $dbSvc;
|
||||
private $importerSvc;
|
||||
private DatabaseService $dbSvc;
|
||||
private ImporterService $importerSvc;
|
||||
|
||||
public function __construct(DatabaseService $dbSvc, ImporterService $importerSvc)
|
||||
{
|
||||
|
||||
@@ -29,14 +29,14 @@ use RuntimeException;
|
||||
|
||||
class InstallerController extends Controller
|
||||
{
|
||||
private $airlineSvc;
|
||||
private $analyticsSvc;
|
||||
private $dbSvc;
|
||||
private $envSvc;
|
||||
private $migrationSvc;
|
||||
private $reqSvc;
|
||||
private $seederSvc;
|
||||
private $userService;
|
||||
private AirlineService $airlineSvc;
|
||||
private AnalyticsService $analyticsSvc;
|
||||
private DatabaseService $dbSvc;
|
||||
private ConfigService $envSvc;
|
||||
private MigrationService $migrationSvc;
|
||||
private RequirementsService $reqSvc;
|
||||
private SeederService $seederSvc;
|
||||
private UserService $userService;
|
||||
|
||||
/**
|
||||
* InstallerController constructor.
|
||||
@@ -326,6 +326,7 @@ class InstallerController extends Controller
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $airline->id,
|
||||
'password' => Hash::make($request->get('password')),
|
||||
'opt_in' => true,
|
||||
];
|
||||
|
||||
$user = $this->userService->createUser($attrs, ['admin']);
|
||||
|
||||
@@ -12,9 +12,9 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateController extends Controller
|
||||
{
|
||||
private $installerSvc;
|
||||
private $migrationSvc;
|
||||
private $seederSvc;
|
||||
private InstallerService $installerSvc;
|
||||
private MigrationService $migrationSvc;
|
||||
private SeederService $seederSvc;
|
||||
|
||||
/**
|
||||
* @param InstallerService $installerSvc
|
||||
|
||||
Reference in New Issue
Block a user