Reworked site setup, added SingleOrFail()
This commit is contained in:
@@ -26,19 +26,26 @@ class SetSite
|
||||
*/
|
||||
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 = new Site;
|
||||
|
||||
if ($so->getTable() AND Schema::hasTable($so->getTable()))
|
||||
$so = Site::where('url',$request->root())->first();
|
||||
$so = Site::where('url',$request->root())->single();
|
||||
|
||||
if ($so && ! $so->active)
|
||||
abort(404);
|
||||
|
||||
// If we dont exist, we'll return a fake model.
|
||||
if ((! $so) || (! $so->exists))
|
||||
$so = (new Site)->sample();
|
||||
if (! $so) {
|
||||
if ($request->ajax())
|
||||
abort(404);
|
||||
|
||||
$so = (new Site);
|
||||
}
|
||||
|
||||
// Set who we are in SETUP.
|
||||
Config::set('SITE_SETUP',$so);
|
||||
View::share('so',$so);
|
||||
if (! $request->ajax())
|
||||
View::share('so',$so);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
Reference in New Issue
Block a user