Updates after 8.0 shift

This commit is contained in:
Adam Lavin 2021-02-14 19:34:53 +00:00
parent 4a37c63876
commit 15e01fcc8d
No known key found for this signature in database
GPG key ID: 9C4C68AFA9CA6461
6 changed files with 1483 additions and 333 deletions

View file

@ -28,7 +28,7 @@ use Throwable;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
/** /**
* A list of the exception types that should not be reported. * A list of the exception types that are not reported.
* *
* @var array * @var array
*/ */
@ -47,27 +47,14 @@ class Handler extends ExceptionHandler
]; ];
/** /**
* Report or log an exception. * Register the exception handling callbacks for the application.
* *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void * @return void
*/ */
public function report(Throwable $e) public function register()
{ {
parent::report($e); $this->reportable(function (Throwable $e) {
} //
});
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Throwable $e)
{
return parent::render($request, $e);
} }
} }

View file

@ -22,6 +22,7 @@ namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider; use App\Providers\RouteServiceProvider;
use Closure; use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated class RedirectIfAuthenticated
@ -31,14 +32,18 @@ class RedirectIfAuthenticated
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard * @param string|null ...$guards
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next, $guard = null) public function handle(Request $request, Closure $next, ...$guards)
{ {
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) { if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME); return redirect(RouteServiceProvider::HOME);
} }
}
return $next($request); return $next($request);
} }

View file

@ -21,28 +21,32 @@
namespace App\Providers; namespace App\Providers;
use App\Models\User; use App\Models\User;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router; use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/** /**
* The path to the "home" route for your application. * The path to the "home" route for your application.
* *
* This is used by Laravel authentication to redirect users after login.
*
* @var string * @var string
*/ */
public const HOME = '/home'; public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/** /**
* Define your route model bindings, pattern filters, etc. * Define your route model bindings, pattern filters, etc.
* *
@ -50,26 +54,34 @@ class RouteServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
parent::boot(); $this->configureRateLimiting();
$this->routes(function () {
Route::model('userId', User::class); Route::model('userId', User::class);
Route::bind('userSlug', function ($value) { Route::bind('userSlug', function ($value) {
return User::where('slug', $value)->first(); return User::where('slug', $value)->first();
}); });
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
} }
/** /**
* Define the routes for the application. * Configure the rate limiters for the application.
* *
* @return void * @return void
*/ */
public function map() protected function configureRateLimiting()
{ {
Route::group([ RateLimiter::for('api', function (Request $request) {
'middleware' => 'web', return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
}); });
} }
} }

View file

@ -10,14 +10,14 @@
"license": "AGPL", "license": "AGPL",
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.3|^8.0", "php": "^7.4|^8.0",
"laravel/framework": "^8.27", "laravel/framework": "^8.27",
"codescale/ffmpeg-php": "2.7.0", "codescale/ffmpeg-php": "2.7.0",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "^7.0.1",
"doctrine/dbal": "^3.0", "doctrine/dbal": "^3.0",
"venturecraft/revisionable": "^1.36", "venturecraft/revisionable": "^1.36",
"pda/pheanstalk": "^4.0", "pda/pheanstalk": "^4.0",
"cviebrock/laravel-elasticsearch": "^4.0", "cviebrock/laravel-elasticsearch": "^8.0",
"barryvdh/laravel-debugbar": "^3.5", "barryvdh/laravel-debugbar": "^3.5",
"predis/predis": "^1.1", "predis/predis": "^1.1",
"ksubileau/color-thief-php": "^1.3", "ksubileau/color-thief-php": "^1.3",
@ -42,7 +42,8 @@
"nategood/httpful": "^0.2.20", "nategood/httpful": "^0.2.20",
"nunomaduro/collision": "^5.0", "nunomaduro/collision": "^5.0",
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",
"facade/ignition": "^2.5" "facade/ignition": "^2.5",
"barryvdh/laravel-ide-helper": "^2.9"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [
@ -67,6 +68,11 @@
"post-create-project-cmd": [ "post-create-project-cmd": [
"@php artisan key:generate --ansi" "@php artisan key:generate --ansi"
], ],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate",
"@php artisan ide-helper:meta"
],
"post-autoload-dump": [ "post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi" "@php artisan package:discover --ansi"

1699
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,18 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php"
bootstrap="vendor/autoload.php"
colors="true"> colors="true">
<coverage>
<include>
<directory suffix=".php">app/</directory>
</include>
</coverage>
<testsuites> <testsuites>
<testsuite name="Application Test Suite"> <testsuite name="Application Test Suite">
<directory>./tests/</directory> <directory>./tests/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist>
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php> <php>
<server name="APP_ENV" value="testing"/> <server name="APP_ENV" value="testing"/>
<server name="APP_KEY" value="CMOxJYitit2cFgI9FbbxJJpWxBBZl6RU"/> <server name="APP_KEY" value="CMOxJYitit2cFgI9FbbxJJpWxBBZl6RU"/>