Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to laravel 10 #638

Merged
merged 7 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.env
.htaccess
.idea/
.phpunit.result.cache
.vscode/
/_ide_helper.php
/.phpstorm.meta.php
Expand All @@ -21,4 +20,8 @@ public/fonts/vendor/*
public/images/logos/*
public/js/*
resources/sass/_env.scss
yarn-error.log
yarn-error.log

# phpunit and results
*.phpunit.cache
*.phpunit.result.cache
9 changes: 0 additions & 9 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

Expand All @@ -12,5 +11,5 @@
*/
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests, ValidatesRequests;
}
10 changes: 6 additions & 4 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
\App\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
];

/**
Expand All @@ -44,19 +45,20 @@ class Kernel extends HttpKernel
];

/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
Expand Down
10 changes: 3 additions & 7 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): ?string
{
if (! $request->expectsJson()) {
return route('login');
}
return $request->expectsJson() ? null : route('login');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;

class CheckForMaintenanceMode extends Middleware
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
* @var array<int, string>
*/
protected $except = [
//
Expand Down
15 changes: 8 additions & 7 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

use Closure;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle($request, Closure $next, string ...$guards): Response
{
if (Auth::guard($guard)->check()) {
return redirect('/dashboard');
$guards = empty($guards) ? [null] : $guards;

foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}

return $next($request);
Expand Down
4 changes: 2 additions & 2 deletions app/Models/ActivityLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ActivityLog extends Model
{
public $timestamps = false;

protected $dates = [
'created_at',
protected $casts = [
'created_at' => 'datetime',
];

public function user()
Expand Down
8 changes: 4 additions & 4 deletions app/Models/AtcActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class AtcActivity extends Model

protected $fillable = ['user_id', 'hours', 'start_of_grace_period'];

protected $dates = [
'created_at',
'updated_at',
'start_of_grace_period',
protected $casts = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_of_grace_period' => 'datetime',
];

public function user()
Expand Down
10 changes: 5 additions & 5 deletions app/Models/Endorsement.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Endorsement extends Model
{
use HasFactory;

protected $dates = [
'valid_from',
'valid_to',
'created_at',
'updated_at',
protected $casts = [
'valid_from' => 'datetime',
'valid_to' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

public function ratings()
Expand Down
8 changes: 4 additions & 4 deletions app/Models/OneTimeLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class OneTimeLink extends Model

public $timestamps = false;

protected $dates = [
'expires_at',
protected $casts = [
'expires_at' => 'datetime',
];

/**
Expand Down Expand Up @@ -45,7 +45,7 @@ public function getLink()
*/
public function reportType()
{
return self::TRAINING_REPORT_TYPE == $this->training_object_type;
return $this->training_object_type == self::TRAINING_REPORT_TYPE;
}

/**
Expand All @@ -55,7 +55,7 @@ public function reportType()
*/
public function examinationType()
{
return self::TRAINING_EXAMINATION_TYPE == $this->training_object_type;
return $this->training_object_type == self::TRAINING_EXAMINATION_TYPE;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Training.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class Training extends Model

protected $table = 'trainings';

protected $dates = [
'started_at',
'closed_at',
protected $casts = [
'started_at' => 'datetime',
'closed_at' => 'datetime',
];

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Models/TrainingExamination.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class TrainingExamination extends TrainingObject

protected $guarded = [];

protected $dates = ['examination_date'];

protected $casts = [
'draft' => 'boolean',
'examination_date' => 'datetime',
];

public function position()
Expand Down
6 changes: 3 additions & 3 deletions app/Models/TrainingInterest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class TrainingInterest extends Model
{
protected $guarded = [];

protected $dates = [
'deadline',
'confirmed_at',
protected $casts = [
'deadline' => 'datetime',
'confirmed_at' => 'datetime',
];

public function training()
Expand Down
3 changes: 1 addition & 2 deletions app/Models/TrainingReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class TrainingReport extends TrainingObject

protected $guarded = [];

protected $dates = ['report_date'];

protected $casts = [
'draft' => 'boolean',
'report_date' => 'datetime',
];

public function path()
Expand Down
8 changes: 4 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class User extends Authenticatable

public $timestamps = false;

protected $dates = [
'last_login',
'last_activity',
'last_inactivity_warning',
protected $casts = [
'last_login' => 'datetime',
'last_activity' => 'datetime',
'last_inactivity_warning' => 'datetime',
];

/**
Expand Down
8 changes: 2 additions & 6 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
//
}
Expand Down
8 changes: 3 additions & 5 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AuthServiceProvider extends ServiceProvider
/**
* The policy mappings for the application.
*
* @var array
* @var array<class-string, class-string>
*/
protected $policies = [
'anlutro\LaravelSettings\Facade' => 'App\Policies\SettingPolicy',
Expand All @@ -18,11 +18,9 @@ class AuthServiceProvider extends ServiceProvider

/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->registerPolicies();
//
}
}
4 changes: 1 addition & 3 deletions app/Providers/BroadcastServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
Broadcast::routes();

Expand Down
14 changes: 9 additions & 5 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ class EventServiceProvider extends ServiceProvider

/**
* Register any events for your application.
*
* @return void
*/
public function boot()
public function boot(): void
{
parent::boot();

//
}

/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}
Loading