Files
faveo/app/Http/Middleware/TicketViewURL.php
Shift 0b263803ad Apply Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions.

You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root.

For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
2023-01-07 20:55:49 +00:00

47 lines
1.6 KiB
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Request;
//use Redirect;
class TicketViewURL
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// dd(Request::all(), $request->fullUrl());
$request_str = $request->fullUrl();
if (preg_match('([^D]=)', $request_str) == 1) {
$request_str = str_replace('=', '%5B%5D=', $request_str);
$request_str = str_replace('%5B%5D%5B%5D=', '%5B%5D=', $request_str);
}
if (count(Request::all()) == 0) {
return \Redirect::to('tickets?show%5B%5D=inbox&departments%5B%5D=All');
} else {
if (! array_key_exists('show', Request::all()) && ! array_key_exists('departments', Request::all())) {
return \Redirect::to($request_str.'&show%5B%5D=inbox&departments%5B%5D=All');
} elseif (! array_key_exists('show', Request::all()) && array_key_exists('departments', Request::all())) {
return \Redirect::to($request_str.'&show%5B%5D=inbox');
} elseif (array_key_exists('show', Request::all()) && ! array_key_exists('departments', Request::all())) {
return \Redirect::to($request_str.'&departments%5B%5D=All');
} else {
// do nothing
}
if (preg_match('([^D]=)', $request->fullUrl()) == 1) {
return \Redirect::to($request_str);
}
return $next($request);
}
}
}