PHP Classes

File: server/app/Http/Middleware/OnlyAdmin.php

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Wallet API and Application   server/app/Http/Middleware/OnlyAdmin.php   Download  
File: server/app/Http/Middleware/OnlyAdmin.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Wallet API and Application
Application to manage a wallet by calling an API
Author: By
Last change:
Date: 2 years ago
Size: 544 bytes
 

Contents

Class file image Download
<?php

namespace App\Http\Middleware;

use
Closure;
use
Illuminate\Http\Request;

/**
 * Middleware disallow users not have admin permissions
 */
class OnlyAdmin
{
   
/**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
   
public function handle(Request $request, Closure $next)
    {
        if (
auth())
            if (
$request->user()->is_admin)
                return
$next($request);
        return
response()->json([], 403);
    }
}