Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel restrict route methods

   public function __construct()
    {
        $this->middleware('auth')->except(['index', 'show']);
    }
Comment

laravel restrict route

namespace AppHttpMiddleware;

use AppArticle;
use Closure;
use IlluminateContractsAuthGuard;

class AdminMiddleware
{
    /**
     * The Guard implementation.
     *
     * @var Guard
     */
    protected $auth;

    /**
     * Create a new filter instance.
     *
     * @param  Guard  $auth
     * @return void
     */
    public function __construct(Guard $auth)
    {
        $this->auth = $auth;
    }

    /**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($this->auth->getUser()->type !== "admin") {
            abort(403, 'Unauthorized action.');
        }

        return $next($request);
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php aes 
Php :: how to setup cron job for laravel queues on shared hosting 
Php :: laravel rule unique where 
Php :: laravel debugbar false 
Php :: $ is not define 
Php :: acos() php 
Php :: drop foreign key laravel eloquent 
Php :: PHP strrpos — Find the position of the last occurrence of a substring in a string 
Php :: php recortar string 
Php :: drupal 7 db_query example 
Php :: how to create php message 3 
Php :: preg_split 
Php :: eloquent insert into select 
Php :: how to use wherehas in laravel 
Php :: downgrade php version 
Php :: string length laravel validation 
Php :: php unit expect exception 
Php :: disadvantages of php 
Php :: get diff array php 
Php :: how to extract data from json in php 
Php :: php get array key like 
Php :: how to filter laravel eloquent 
Php :: how to rename a table element in laravel 
Php :: php ErrorException Undefined variable inside array_map 
Php :: magento 2 select to string 
Php :: remove duplicate characters in a string in php 
Php :: laravel custom validation 
Php :: laravel 7 requirements 
Php :: php rtrim 
Php :: laravel OrderBy on Eloquent whereHas relationship 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =