Upgrade to Laravel 10

This commit is contained in:
Jonny Barnes 2023-02-18 09:34:57 +00:00
commit 16b120bc73
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
142 changed files with 1676 additions and 2019 deletions

View file

@ -5,17 +5,23 @@ root = true
# Unix-style newlines with a newline ending every file # Unix-style newlines with a newline ending every file
[*] [*]
end_of_line = lf
charset = utf-8 charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
indent_style = space
indent_size = 4
# Tab indentation # Tab indentation
[Makefile] [Makefile]
indent_style = tab indent_style = tab
tab_width = 4 tab_width = 4
[yml] [*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2 indent_size = 2
[docker-compose.yml]
indent_size = 4

View file

@ -25,22 +25,10 @@ class MigratePlaceDataFromPostgis extends Command
*/ */
protected $description = 'Copy Postgis data to normal latitude longitude fields'; protected $description = 'Copy Postgis data to normal latitude longitude fields';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*
* @return int
*/ */
public function handle() public function handle(): int
{ {
$locationColumn = DB::selectOne(DB::raw(" $locationColumn = DB::selectOne(DB::raw("
SELECT EXISTS ( SELECT EXISTS (

View file

@ -6,6 +6,7 @@ namespace App\Console\Commands;
use App\Models\WebMention; use App\Models\WebMention;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\FileSystem\FileSystem; use Illuminate\FileSystem\FileSystem;
class ParseCachedWebMentions extends Command class ParseCachedWebMentions extends Command
@ -27,9 +28,9 @@ class ParseCachedWebMentions extends Command
/** /**
* Execute the console command. * Execute the console command.
* *
* @return mixed * @throws FileNotFoundException
*/ */
public function handle(FileSystem $filesystem) public function handle(FileSystem $filesystem): void
{ {
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML'); $htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
foreach ($htmlFiles as $file) { foreach ($htmlFiles as $file) {
@ -49,8 +50,6 @@ class ParseCachedWebMentions extends Command
/** /**
* Determine the source URL from a filename. * Determine the source URL from a filename.
*
* @param string
*/ */
private function urlFromFilename(string $filepath): string private function urlFromFilename(string $filepath): string
{ {

View file

@ -24,22 +24,10 @@ class ReDownloadWebMentions extends Command
*/ */
protected $description = 'Redownload the HTML content of webmentions'; protected $description = 'Redownload the HTML content of webmentions';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*
* @return mixed
*/ */
public function handle() public function handle(): void
{ {
$webmentions = WebMention::all(); $webmentions = WebMention::all();
foreach ($webmentions as $webmention) { foreach ($webmentions as $webmention) {

View file

@ -10,7 +10,7 @@ class Kernel extends ConsoleKernel
/** /**
* The Artisan commands provided by your application. * The Artisan commands provided by your application.
* *
* @var array * @var array<int, string>
*/ */
protected $commands = [ protected $commands = [
Commands\ParseCachedWebMentions::class, Commands\ParseCachedWebMentions::class,
@ -20,11 +20,9 @@ class Kernel extends ConsoleKernel
/** /**
* Define the application's command schedule. * Define the application's command schedule.
* *
* @return void
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule): void
{ {
$schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->command('cache:prune-stale-tags')->hourly(); $schedule->command('cache:prune-stale-tags')->hourly();
@ -32,10 +30,8 @@ class Kernel extends ConsoleKernel
/** /**
* Register the commands for the application. * Register the commands for the application.
*
* @return void
*/ */
protected function commands() protected function commands(): void
{ {
$this->load(__DIR__ . '/Commands'); $this->load(__DIR__ . '/Commands');

View file

@ -21,46 +21,34 @@ class Handler extends ExceptionHandler
/** /**
* A list of the exception types that are not reported. * A list of the exception types that are not reported.
* *
* @var array * @var array<int, class-string<\Throwable>>
*/ */
protected $dontReport = [ protected $dontReport = [
NotFoundHttpException::class, NotFoundHttpException::class,
ModelNotFoundException::class, ModelNotFoundException::class,
]; ];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/** /**
* Report or log an exception. * Report or log an exception.
* *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* *
* @return void
*
* @throws Exception * @throws Exception
* @throws Throwable * @throws Throwable
*/ */
public function report(Throwable $throwable) public function report(Throwable $e): void
{ {
parent::report($throwable); parent::report($e);
if (config('logging.slack') && $this->shouldReport($throwable)) { if (config('logging.slack') && $this->shouldReport($e)) {
$guzzle = new Client([ $guzzle = new Client([
'headers' => [ 'headers' => [
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
], ],
]); ]);
$exceptionName = get_class($throwable) ?? 'Unknown Exception'; $exceptionName = get_class($e) ?? 'Unknown Exception';
$title = $exceptionName . ': ' . $throwable->getMessage(); $title = $exceptionName . ': ' . $e->getMessage();
$guzzle->post( $guzzle->post(
config('logging.slack'), config('logging.slack'),

View file

@ -27,10 +27,8 @@ class ArticlesController extends Controller
/** /**
* Show a single article. * Show a single article.
*
* @return RedirectResponse|View
*/ */
public function show(int $year, int $month, string $slug) public function show(int $year, int $month, string $slug): RedirectResponse|View
{ {
try { try {
$article = Article::where('titleurl', $slug)->firstOrFail(); $article = Article::where('titleurl', $slug)->firstOrFail();
@ -49,8 +47,7 @@ class ArticlesController extends Controller
} }
/** /**
* We only have the ID, work out post title, year and month * We only have the ID, work out post title, year and month and redirect to it.
* and redirect to it.
*/ */
public function onlyIdInUrl(string $idFromUrl): RedirectResponse public function onlyIdInUrl(string $idFromUrl): RedirectResponse
{ {

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\View\View; use Illuminate\View\View;
@ -12,10 +13,8 @@ class AuthController extends Controller
{ {
/** /**
* Show the login form. * Show the login form.
*
* @return View|RedirectResponse
*/ */
public function showLogin() public function showLogin(): View|RedirectResponse
{ {
if (Auth::check()) { if (Auth::check()) {
return redirect('/'); return redirect('/');
@ -25,12 +24,11 @@ class AuthController extends Controller
} }
/** /**
* Log in a user, set a session variable, check credentials against * Log in a user, set a session variable, check credentials against the `.env` file.
* the .env file.
*/ */
public function login(): RedirectResponse public function login(Request $request): RedirectResponse
{ {
$credentials = request()->only('name', 'password'); $credentials = $request->only('name', 'password');
if (Auth::attempt($credentials, true)) { if (Auth::attempt($credentials, true)) {
return redirect()->intended('/'); return redirect()->intended('/');
@ -40,11 +38,9 @@ class AuthController extends Controller
} }
/** /**
* Show the form to logout a user. * Show the form to allow a user to log-out.
*
* @return View|RedirectResponse
*/ */
public function showLogout() public function showLogout(): View|RedirectResponse
{ {
if (Auth::check() === false) { if (Auth::check() === false) {
// The user is not logged in, just redirect them home // The user is not logged in, just redirect them home
@ -56,8 +52,6 @@ class AuthController extends Controller
/** /**
* Log the user out from their current session. * Log the user out from their current session.
*
* @return RedirectResponse;
*/ */
public function logout(): RedirectResponse public function logout(): RedirectResponse
{ {

View file

@ -96,10 +96,8 @@ class FeedsController extends Controller
/** /**
* Returns the notes JSON feed. * Returns the notes JSON feed.
*
* @return array
*/ */
public function notesJson() public function notesJson(): array
{ {
$notes = Note::latest()->with('media')->take(20)->get(); $notes = Note::latest()->with('media')->take(20)->get();
$data = [ $data = [

View file

@ -7,6 +7,7 @@ use App\Models\Bookmark;
use App\Models\Like; use App\Models\Like;
use App\Models\Note; use App\Models\Note;
use App\Services\ActivityStreamsService; use App\Services\ActivityStreamsService;
use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\View\View; use Illuminate\View\View;
@ -14,12 +15,10 @@ class FrontPageController extends Controller
{ {
/** /**
* Show all the recent activity. * Show all the recent activity.
*
* @return Response|View
*/ */
public function index() public function index(Request $request): Response|View
{ {
if (request()->wantsActivityStream()) { if ($request->wantsActivityStream()) {
return (new ActivityStreamsService())->siteOwnerResponse(); return (new ActivityStreamsService())->siteOwnerResponse();
} }

View file

@ -115,34 +115,34 @@ class MicropubController extends Controller
* appropriately. Further if the request has the query parameter * appropriately. Further if the request has the query parameter
* syndicate-to we respond with the known syndication endpoints. * syndicate-to we respond with the known syndication endpoints.
*/ */
public function get(): JsonResponse public function get(Request $request): JsonResponse
{ {
try { try {
$tokenData = $this->tokenService->validateToken(request()->input('access_token')); $tokenData = $this->tokenService->validateToken($request->input('access_token'));
} catch (RequiredConstraintsViolated|InvalidTokenStructure) { } catch (RequiredConstraintsViolated|InvalidTokenStructure) {
return (new MicropubResponses())->invalidTokenResponse(); return (new MicropubResponses())->invalidTokenResponse();
} }
if (request()->input('q') === 'syndicate-to') { if ($request->input('q') === 'syndicate-to') {
return response()->json([ return response()->json([
'syndicate-to' => SyndicationTarget::all(), 'syndicate-to' => SyndicationTarget::all(),
]); ]);
} }
if (request()->input('q') === 'config') { if ($request->input('q') === 'config') {
return response()->json([ return response()->json([
'syndicate-to' => SyndicationTarget::all(), 'syndicate-to' => SyndicationTarget::all(),
'media-endpoint' => route('media-endpoint'), 'media-endpoint' => route('media-endpoint'),
]); ]);
} }
if (request()->has('q') && substr(request()->input('q'), 0, 4) === 'geo:') { if ($request->has('q') && str_starts_with($request->input('q'), 'geo:')) {
preg_match_all( preg_match_all(
'/([0-9.\-]+)/', '/([0-9.\-]+)/',
request()->input('q'), $request->input('q'),
$matches $matches
); );
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000; $distance = (count($matches[0]) === 3) ? 100 * $matches[0][2] : 1000;
$places = Place::near( $places = Place::near(
(object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]], (object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]],
$distance $distance
@ -168,22 +168,19 @@ class MicropubController extends Controller
/** /**
* Determine the client id from the access token sent with the request. * Determine the client id from the access token sent with the request.
* *
*
* @throws RequiredConstraintsViolated * @throws RequiredConstraintsViolated
*/ */
private function getClientId(): string private function getClientId(): string
{ {
return resolve(TokenService::class) return resolve(TokenService::class)
->validateToken(request()->input('access_token')) ->validateToken(app('request')->input('access_token'))
->claims()->get('client_id'); ->claims()->get('client_id');
} }
/** /**
* Save the details of the micropub request to a log file. * Save the details of the micropub request to a log file.
*
* @param array $request This is the info from request()->all()
*/ */
private function logMicropubRequest(array $request) private function logMicropubRequest(array $request): void
{ {
$logger = new Logger('micropub'); $logger = new Logger('micropub');
$logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log'))); $logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log')));

View file

@ -98,14 +98,13 @@ class MicropubMediaController extends Controller
/** /**
* Process a media item posted to the media endpoint. * Process a media item posted to the media endpoint.
* *
*
* @throws BindingResolutionException * @throws BindingResolutionException
* @throws Exception * @throws Exception
*/ */
public function media(): JsonResponse public function media(Request $request): JsonResponse
{ {
try { try {
$tokenData = $this->tokenService->validateToken(request()->input('access_token')); $tokenData = $this->tokenService->validateToken($request->input('access_token'));
} catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) { } catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) {
$micropubResponses = new MicropubResponses(); $micropubResponses = new MicropubResponses();
@ -124,7 +123,7 @@ class MicropubMediaController extends Controller
return $micropubResponses->insufficientScopeResponse(); return $micropubResponses->insufficientScopeResponse();
} }
if (request()->hasFile('file') === false) { if ($request->hasFile('file') === false) {
return response()->json([ return response()->json([
'response' => 'error', 'response' => 'error',
'error' => 'invalid_request', 'error' => 'invalid_request',
@ -132,7 +131,7 @@ class MicropubMediaController extends Controller
], 400); ], 400);
} }
if (request()->file('file')->isValid() === false) { if ($request->file('file')->isValid() === false) {
return response()->json([ return response()->json([
'response' => 'error', 'response' => 'error',
'error' => 'invalid_request', 'error' => 'invalid_request',
@ -140,11 +139,11 @@ class MicropubMediaController extends Controller
], 400); ], 400);
} }
$filename = $this->saveFile(request()->file('file')); $filename = $this->saveFile($request->file('file'));
$manager = resolve(ImageManager::class); $manager = resolve(ImageManager::class);
try { try {
$image = $manager->make(request()->file('file')); $image = $manager->make($request->file('file'));
$width = $image->width(); $width = $image->width();
} catch (NotReadableException $exception) { } catch (NotReadableException $exception) {
// not an image // not an image
@ -152,9 +151,9 @@ class MicropubMediaController extends Controller
} }
$media = Media::create([ $media = Media::create([
'token' => request()->bearerToken(), 'token' => $request->bearerToken(),
'path' => 'media/' . $filename, 'path' => 'media/' . $filename,
'type' => $this->getFileTypeFromMimeType(request()->file('file')->getMimeType()), 'type' => $this->getFileTypeFromMimeType($request->file('file')->getMimeType()),
'image_widths' => $width, 'image_widths' => $width,
]); ]);
@ -226,7 +225,6 @@ class MicropubMediaController extends Controller
/** /**
* Save an uploaded file to the local disk. * Save an uploaded file to the local disk.
* *
*
* @throws Exception * @throws Exception
*/ */
private function saveFile(UploadedFile $file): string private function saveFile(UploadedFile $file): string

View file

@ -9,6 +9,7 @@ use App\Services\ActivityStreamsService;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\View\View; use Illuminate\View\View;
use Jonnybarnes\IndieWeb\Numbers; use Jonnybarnes\IndieWeb\Numbers;
@ -19,12 +20,10 @@ class NotesController extends Controller
{ {
/** /**
* Show all the notes. This is also the homepage. * Show all the notes. This is also the homepage.
*
* @return View|Response
*/ */
public function index() public function index(Request $request): View|Response
{ {
if (request()->wantsActivityStream()) { if ($request->wantsActivityStream()) {
return (new ActivityStreamsService())->siteOwnerResponse(); return (new ActivityStreamsService())->siteOwnerResponse();
} }
@ -39,11 +38,8 @@ class NotesController extends Controller
/** /**
* Show a single note. * Show a single note.
*
* @param string $urlId The id of the note
* @return View|JsonResponse|Response
*/ */
public function show(string $urlId) public function show(string $urlId): View|JsonResponse|Response
{ {
try { try {
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail(); $note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
@ -60,8 +56,6 @@ class NotesController extends Controller
/** /**
* Redirect /note/{decID} to /notes/{nb60id}. * Redirect /note/{decID} to /notes/{nb60id}.
*
* @param int $decId The decimal id of the note
*/ */
public function redirect(int $decId): RedirectResponse public function redirect(int $decId): RedirectResponse
{ {

View file

@ -35,17 +35,15 @@ class ShortURLsController extends Controller
/** /**
* Redirect a short url of this site out to a long one based on post type. * Redirect a short url of this site out to a long one based on post type.
* Further redirects may happen.
* *
* @param string Post type * Further redirects may happen.
* @param string Post ID
*/ */
public function expandType(string $type, string $postId): RedirectResponse public function expandType(string $type, string $postId): RedirectResponse
{ {
if ($type == 't') { if ($type === 't') {
$type = 'notes'; $type = 'notes';
} }
if ($type == 'b') { if ($type === 'b') {
$type = 'blog/s'; $type = 'blog/s';
} }

View file

@ -24,9 +24,6 @@ class TokenEndpointController extends Controller
*/ */
protected GuzzleClient $guzzle; protected GuzzleClient $guzzle;
/**
* @var TokenService The Token handling service.
*/
protected TokenService $tokenService; protected TokenService $tokenService;
/** /**

View file

@ -7,6 +7,7 @@ namespace App\Http\Controllers;
use App\Jobs\ProcessWebMention; use App\Jobs\ProcessWebMention;
use App\Models\Note; use App\Models\Note;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\View\View; use Illuminate\View\View;
use Jonnybarnes\IndieWeb\Numbers; use Jonnybarnes\IndieWeb\Numbers;
@ -27,10 +28,10 @@ class WebMentionsController extends Controller
/** /**
* Receive and process a webmention. * Receive and process a webmention.
*/ */
public function receive(): Response public function receive(Request $request): Response
{ {
//first we trivially reject requests that lack all required inputs //first we trivially reject requests that lack all required inputs
if ((request()->has('target') !== true) || (request()->has('source') !== true)) { if (($request->has('target') !== true) || ($request->has('source') !== true)) {
return response( return response(
'You need both the target and source parameters', 'You need both the target and source parameters',
400 400
@ -38,15 +39,15 @@ class WebMentionsController extends Controller
} }
//next check the $target is valid //next check the $target is valid
$path = parse_url(request()->input('target'), PHP_URL_PATH); $path = parse_url($request->input('target'), PHP_URL_PATH);
$pathParts = explode('/', $path); $pathParts = explode('/', $path);
if ($pathParts[1] == 'notes') { if ($pathParts[1] === 'notes') {
//we have a note //we have a note
$noteId = $pathParts[2]; $noteId = $pathParts[2];
try { try {
$note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId)); $note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId));
dispatch(new ProcessWebMention($note, request()->input('source'))); dispatch(new ProcessWebMention($note, $request->input('source')));
} catch (ModelNotFoundException $e) { } catch (ModelNotFoundException $e) {
return response('This note doesn’t exist.', 400); return response('This note doesn’t exist.', 400);
} }
@ -56,7 +57,7 @@ class WebMentionsController extends Controller
202 202
); );
} }
if ($pathParts[1] == 'blog') { if ($pathParts[1] === 'blog') {
return response( return response(
'I don’t accept webmentions for blog posts yet.', 'I don’t accept webmentions for blog posts yet.',
501 501

View file

@ -11,7 +11,7 @@ class Kernel extends HttpKernel
* *
* These middleware are run during every request to your application. * These middleware are run during every request to your application.
* *
* @var array * @var array<int, class-string|string>
*/ */
protected $middleware = [ protected $middleware = [
// \App\Http\Middleware\TrustHosts::class, // \App\Http\Middleware\TrustHosts::class,
@ -26,7 +26,7 @@ class Kernel extends HttpKernel
/** /**
* The application's route middleware groups. * The application's route middleware groups.
* *
* @var array * @var array<string, array<int, class-string|string>>
*/ */
protected $middlewareGroups = [ protected $middlewareGroups = [
'web' => [ 'web' => [
@ -44,21 +44,23 @@ class Kernel extends HttpKernel
], ],
'api' => [ 'api' => [
'throttle:api', // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
], ],
]; ];
/** /**
* The application's route middleware. * The application's middleware aliases.
* *
* These middleware may be assigned to groups or used individually. * Aliases may be used to conveniently assign middleware to routes and groups.
* *
* @var array * @var array<string, class-string|string>
*/ */
protected $middlewareAliases = [ protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class, 'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,

View file

@ -6,15 +6,14 @@ namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ActivityStreamLinks class ActivityStreamLinks
{ {
/** /**
* Handle an incoming request. * Handle an incoming request.
*
* @return mixed
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, Closure $next): Response
{ {
$response = $next($request); $response = $next($request);
if ($request->path() === '/') { if ($request->path() === '/') {

View file

@ -3,6 +3,7 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
@ -11,14 +12,9 @@ class Authenticate extends Middleware
{ {
/** /**
* Get the path the user should be redirected to when they are not authenticated. * 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 $request->expectsJson() ? null : route('login');
return route('login');
}
} }
} }

View file

@ -5,16 +5,14 @@ namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Symfony\Component\HttpFoundation\Response;
class CSPHeader class CSPHeader
{ {
/** /**
* Handle an incoming request. * Handle an incoming request.
*
* @param Request $request
* @return mixed
*/ */
public function handle($request, Closure $next) public function handle(Request $request, Closure $next): Response
{ {
if (App::environment('local', 'development')) { if (App::environment('local', 'development')) {
return $next($request); return $next($request);

Some files were not shown because too many files have changed in this diff Show more