<?php

namespace App\Http\Middleware;

use Closure;
use Redirect;
use Illuminate\Http\Request;
use App\Models\Ticket;


class CanEditPassenger
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
       
        $path_parts=explode('/',url()->full());
        $id=(int)$path_parts[4];
          $ticket=   Ticket::find($id);
        //   dd($ticket);
          if($ticket->ticket_status =='U'){
             return abort(404);

          }
          return $next($request);

       
    }
}
