PHP Classes

File: apps/MS-AvailableHotels/app/Http/Middleware/Authenticate.php

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Hotel Booking Available   apps/MS-AvailableHotels/app/Http/Middleware/Authenticate.php   Download  
File: apps/MS-AvailableHotels/app/Http/Middleware/Authenticate.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Hotel Booking Available
Search for hotels that are available for booking
Author: By
Last change:
Date: 2 years ago
Size: 911 bytes
 

Contents

Class file image Download
<?php

namespace App\Http\Middleware;

use
Closure;
use
Illuminate\Contracts\Auth\Factory as Auth;

class
Authenticate
{
   
/**
     * The authentication guard factory instance.
     *
     * @var \Illuminate\Contracts\Auth\Factory
     */
   
protected $auth;

   
/**
     * Create a new middleware instance.
     *
     * @param \Illuminate\Contracts\Auth\Factory $auth
     * @return void
     */
   
public function __construct(Auth $auth)
    {
       
$this->auth = $auth;
    }

   
/**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @param string|null $guard
     * @return mixed
     */
   
public function handle($request, Closure $next, $guard = null)
    {
        if (
$this->auth->guard($guard)->guest()) {
            return
response('Unauthorized.', 401);
        }

        return
$next($request);
    }
}