This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
memberdb/app/Http/Middleware/SetSite.php

43 lines
849 B
PHP
Raw Normal View History

<?php
namespace App\Http\Middleware;
use Closure;
use App\Models\{Setup,Site};
use Config;
use View;
use Theme;
class SetSite
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// @todo Figure out how to know if this is an API call - and deny it if it's not in the database.
$so = Setup::where('url',$request->root())
->orwhere('urldev',$request->root())
// @todo With an API call, we would use ->firstorfail();
->first();
// If we dont exist, we'll return an empty model.
if (! $so) {
$so = new Setup;
$so->site = new Site;
}
Theme::set('metronic-fe');
// Set who we are in SETUP.
Config::set('SITE_SETUP',$so);
View::share('so',$so);
return $next($request);
}
}