Skip to content

Commit

Permalink
Update Laradminator to laravel 8
Browse files Browse the repository at this point in the history
  • Loading branch information
kossa committed Sep 14, 2020
1 parent 5e0068e commit e4b441b
Show file tree
Hide file tree
Showing 31 changed files with 1,141 additions and 600 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
12 changes: 6 additions & 6 deletions _ide_helper.php
Expand Up @@ -1636,7 +1636,7 @@ public static function getDefaultUserProvider()
/**
* Get the currently authenticated user.
*
* @return \App\User|null
* @return \App\Models\User|null
* @static
*/
public static function user()
Expand Down Expand Up @@ -1671,7 +1671,7 @@ public static function once($credentials = array())
* Log the given user ID into the application without sessions or cookies.
*
* @param mixed $id
* @return \App\User|false
* @return \App\Models\User|false
* @static
*/
public static function onceUsingId($id)
Expand Down Expand Up @@ -1735,7 +1735,7 @@ public static function attempt($credentials = array(), $remember = false)
*
* @param mixed $id
* @param bool $remember
* @return \App\User|false
* @return \App\Models\User|false
* @static
*/
public static function loginUsingId($id, $remember = false)
Expand Down Expand Up @@ -1782,7 +1782,7 @@ public static function attempting($callback)
/**
* Get the last user we attempted to authenticate.
*
* @return \App\User
* @return \App\Models\User
* @static
*/
public static function getLastAttempted()
Expand Down Expand Up @@ -1884,7 +1884,7 @@ public static function getSession()
/**
* Return the currently cached user.
*
* @return \App\User|null
* @return \App\Models\User|null
* @static
*/
public static function getUser()
Expand Down Expand Up @@ -1930,7 +1930,7 @@ public static function setRequest($request)
/**
* Determine if the current user is authenticated.
*
* @return \App\User
* @return \App\Models\User
* @throws \Illuminate\Auth\AuthenticationException
* @static
*/
Expand Down
24 changes: 3 additions & 21 deletions app/Exceptions/Handler.php
Expand Up @@ -3,7 +3,6 @@
namespace App\Exceptions;

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

class Handler extends ExceptionHandler
{
Expand All @@ -27,29 +26,12 @@ class Handler extends ExceptionHandler
];

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

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
//
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Auth;

use App\User;
use App\Models\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
Expand Down Expand Up @@ -58,7 +58,7 @@ protected function validator(array $data)
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
* @return \App\Models\User
*/
protected function create(array $data)
{
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/UserController.php
Expand Up @@ -4,7 +4,7 @@

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Models\User;

class UserController extends Controller
{
Expand Down Expand Up @@ -97,7 +97,6 @@ public function destroy($id)
{
User::destroy($id);

return back()->withSuccess(trans('app.success_destroy'));
return back()->withSuccess(trans('app.success_destroy'));
}
}

8 changes: 4 additions & 4 deletions app/Http/Kernel.php
Expand Up @@ -14,9 +14,10 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
Expand All @@ -39,7 +40,7 @@ class Kernel extends HttpKernel
],

'api' => [
'throttle:60,1',
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
Expand All @@ -54,15 +55,14 @@ class Kernel extends HttpKernel
protected $routeMiddleware = [
'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,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

'Role' => \App\Http\Middleware\Role::class,
];
}
17 changes: 17 additions & 0 deletions app/Http/Middleware/PreventRequestsDuringMaintenance.php
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Middleware;

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

class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
12 changes: 8 additions & 4 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Expand Up @@ -13,13 +13,17 @@ class RedirectIfAuthenticated
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param string|null ...$guards
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle($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);
Expand Down
20 changes: 20 additions & 0 deletions app/Http/Middleware/TrustHosts.php
@@ -0,0 +1,20 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustHosts as Middleware;

class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}
2 changes: 1 addition & 1 deletion app/Http/Middleware/TrustProxies.php
Expand Up @@ -10,7 +10,7 @@ class TrustProxies extends Middleware
/**
* The trusted proxies for this application.
*
* @var array|string
* @var array|string|null
*/
protected $proxies;

Expand Down
5 changes: 3 additions & 2 deletions app/User.php → app/Models/User.php
@@ -1,14 +1,15 @@
<?php

namespace App;
namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
use Notifiable;
use HasFactory, Notifiable;

/**
* The attributes that are mass assignable.
Expand Down
3 changes: 3 additions & 0 deletions app/Providers/AppServiceProvider.php
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

Expand All @@ -24,6 +25,8 @@ public function register()
*/
public function boot()
{
Paginator::useBootstrap();

if (!defined('ADMIN')) {
define('ADMIN', config('variables.APP_ADMIN', 'admin'));
}
Expand Down
2 changes: 0 additions & 2 deletions app/Providers/EventServiceProvider.php
Expand Up @@ -27,8 +27,6 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
parent::boot();

//
}
}
63 changes: 23 additions & 40 deletions app/Providers/RouteServiceProvider.php
Expand Up @@ -2,7 +2,10 @@

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
Expand All @@ -19,62 +22,42 @@ class RouteServiceProvider extends ServiceProvider
/**
* 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.
*
* @return void
*/
public function boot()
{
//

parent::boot();
$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 routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();

$this->mapWebRoutes();

//
}

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
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);
});
}
}

0 comments on commit e4b441b

Please sign in to comment.