Files
faveo/app/Http/Middleware/Redirect.php
Shift 87acc30a0b 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:32:31 +00:00

49 lines
1.1 KiB
PHP

<?php
namespace App\Http\Middleware;
use Closure;
class Redirect
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$root = $request->root(); //http://localhost/faveo/Faveo-Helpdesk-Pro-fork/public
$url = $this->setAppUrl($request);
if ($url == $root) {
return $next($request);
}
$seg = '';
$segments = $request->segments();
if (count($segments) > 0) {
foreach ($segments as $segment) {
$seg .= '/'.$segment;
}
}
$url = $url.$seg;
return redirect($url);
}
public function setAppUrl($request)
{
$url = $request->root();
if (isInstall()) {
$schema = new \App\Model\helpdesk\Settings\CommonSettings();
$row = $schema->getOptionValue('url', 'app_url', true);
if ($row) {
$url = $row->option_value;
}
}
return $url;
}
}