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

Instructions to add Admin Middleware #22

Open
marceloxp opened this issue May 29, 2018 · 0 comments
Open

Instructions to add Admin Middleware #22

marceloxp opened this issue May 29, 2018 · 0 comments

Comments

@marceloxp
Copy link

Add Admin User Auth Middleware

Create Adminer Middleware

php artisan make:middleware Adminer

File /app/Http/Middleware/Adminer.php:

<?php

namespace App\Http\Middleware;

use Auth;
use Closure;

class Adminer
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (!Auth::check())
        {
            return redirect()->route('login');
        }

        return $next($request);
    }
}

Change /app/Http/Kernel.php:

    protected $routeMiddleware = [
        ...
		'adminer' => 'App\Http\Middleware\Adminer',
    ];

Add auto-login route:

Route::any('adminer', '\Miroc\LaravelAdminer\AdminerAutologinController@index')->middleware('adminer');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant