/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAdmin()) { return $next($request); } // All Agents have access in none restricted mode if (Setting::grab('agent_restrict') == 'no') { if (Agent::isAgent()) { return $next($request); } } // if this is a ticket show page if ($request->route()->getName() == Setting::grab('main_route') . '.show') { $ticket_id = $request->route(Setting::grab('main_route')); } // if this is a new comment on a ticket if ($request->route()->getName() == Setting::grab('main_route') . '-comment.store') { $ticket_id = $request->get('ticket_id'); } // Assigned Agent has access in the restricted mode enabled if (Agent::isAgent() && Agent::isAssignedAgent($ticket_id)) { return $next($request); } // Ticket Owner has access if (Agent::isTicketOwner($ticket_id)) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', trans('ticketit::lang.you-are-not-permitted-to-access')); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAgent() || Agent::isAdmin()) { return $next($request); } return back()->with('warning', 'You are not permitted to access this page!'); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAgent() || Agent::isAdmin()) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', trans('ticketit::lang.you-are-not-permitted-to-access')); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAgent() || Agent::isAdmin()) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', 'You are not permitted to access this page!'); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAdmin()) { return $next($request); } // All Agents have access in none restricted mode if (config('ticketit.agent_restrict') == 'no') { if (Agent::isAgent()) { return $next($request); } } // if this is a ticket show page if ($request->route()->getName() == config('ticketit.main_route') . '.show') { $ticket_id = $request->route(config('ticketit.main_route')); } // if this is a new comment on a ticket if ($request->route()->getName() == config('ticketit.main_route') . '-comment.store') { $ticket_id = $request->get('ticket_id'); } // Assigned Agent has access in the restricted mode enabled if (Agent::isAgent() && Agent::isAssignedAgent($ticket_id)) { return $next($request); } // Ticket Owner has access if (Agent::isTicketOwner($ticket_id)) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', 'You are not permitted to access this page!'); }
/** * Display a listing of tickets related to user. * * @return Response */ public function index() { $items = config('ticketit.paginate_items'); if (Models\Agent::isAdmin()) { $tickets = Models\Ticket::orderBy('updated_at', 'desc')->paginate($items); } elseif (Models\Agent::isAgent()) { $agent = Models\Agent::find(\Auth::user()->id); $tickets = $agent->agentTickets()->orderBy('updated_at', 'desc')->paginate($items); } else { $user = Models\Agent::find(\Auth::user()->id); $tickets = $user->userTickets()->orderBy('updated_at', 'desc')->paginate($items); } return view('ticketit::index', compact('tickets')); }