Skip to content

Commit

Permalink
Laravel 8.x compatibility added
Browse files Browse the repository at this point in the history
  • Loading branch information
Jobinjose01 committed Jan 7, 2023
1 parent 37f7041 commit 16f0785
Show file tree
Hide file tree
Showing 11 changed files with 3,811 additions and 1,720 deletions.
34 changes: 10 additions & 24 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
Expand All @@ -19,37 +19,23 @@ class Handler extends ExceptionHandler
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Report or log an exception.
* Register the exception handling callbacks for the application.
*
* @param \Exception $exception
* @return void
*
* @throws \Exception
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
public function render($request, Exception $exception)
public function register()
{
return parent::render($request, $exception);
$this->reportable(function (Throwable $e) {
//
});
}
}
}
19 changes: 12 additions & 7 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class RedirectIfAuthenticated
Expand All @@ -12,16 +13,20 @@ class RedirectIfAuthenticated
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, ...$guards)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
$guards = empty($guards) ? [null] : $guards;

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

return $next($request);
}
}
}
1 change: 1 addition & 0 deletions app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TrimStrings extends Middleware
* @var array
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace App\Http\Middleware;

use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
* @var array<int, string>|string|null
*/
protected $proxies;

Expand All @@ -19,5 +19,10 @@ class TrustProxies extends Middleware
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public function boot()
{
//
}
}
}
6 changes: 3 additions & 3 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class AuthServiceProvider extends ServiceProvider
/**
* The policy mappings for the application.
*
* @var array
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];

/**
Expand All @@ -27,4 +27,4 @@ public function boot()

//
}
}
}
2 changes: 1 addition & 1 deletion app/Providers/BroadcastServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public function boot()

require base_path('routes/channels.php');
}
}
}
6 changes: 2 additions & 4 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EventServiceProvider extends ServiceProvider
/**
* The event listener mappings for the application.
*
* @var array
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
Expand All @@ -27,8 +27,6 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
parent::boot();

//
}
}
}
75 changes: 29 additions & 46 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,62 @@

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* 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.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';

/**
* Define your route model bindings, pattern filters, etc.
* The controller namespace for the application.
*
* @return void
*/
public function boot()
{
//

parent::boot();
}

/**
* Define the routes for the application.
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @return void
* @var string|null
*/
public function map()
{
$this->mapApiRoutes();

$this->mapWebRoutes();

//
}
// protected $namespace = 'App\\Http\\Controllers';

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
protected function mapWebRoutes()
public function boot()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
$this->configureRateLimiting();

$this->routes(function () {
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 "api" routes for the application.
*
* These routes are typically stateless.
* Configure the rate limiters for the application.
*
* @return void
*/
protected function mapApiRoutes()
protected function configureRateLimiting()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}
}
34 changes: 19 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
],
"license": "MIT",
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.18.35",
"laravel/tinker": "^2.0",
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"laravel/framework": "^8.75",
"laravel/tinker": "^2.5",
"laravelcollective/html": "^6.1",
"laravel/sanctum": "^2.11",
"guzzlehttp/guzzle": "^7.0.1",
"yajra/laravel-datatables-oracle": "~9.0"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
"config": {
"optimize-autoloader": true,
Expand All @@ -35,12 +38,10 @@
"autoload": {
"psr-4": {
"App\\": "app/",
"ExtensionsValley\\Dashboard\\":"packages/ExtensionsValley/Dashboard/src"
},
"classmap": [
"database/seeds",
"database/factories"
]
"ExtensionsValley\\Dashboard\\":"packages/ExtensionsValley/Dashboard/src",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
Expand All @@ -54,6 +55,9 @@
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
Expand Down
Loading

0 comments on commit 16f0785

Please sign in to comment.