Update SiteController

This commit is contained in:
Daniel Supernault 2020-12-26 20:28:12 -07:00
parent 799a4cba12
commit b74e14c4e5
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -62,20 +62,16 @@ class SiteController extends Controller
public function about() public function about()
{ {
return Cache::remember('site:about', now()->addHours(12), function() { $page = Page::whereSlug('/site/about')->whereActive(true)->first();
app()->setLocale('en'); $stats = Cache::remember('site:about:stats-v1', now()->addHours(12), function() {
$page = Page::whereSlug('/site/about')->whereActive(true)->first(); return [
$stats = [ 'posts' => Status::count(),
'posts' => Status::whereLocal(true)->count(),
'users' => User::whereNull('status')->count(), 'users' => User::whereNull('status')->count(),
'admin' => User::whereIsAdmin(true)->first() 'admin' => User::whereIsAdmin(true)->first()
]; ];
if($page) {
return View::make('site.about-custom')->with(compact('page', 'stats'))->render();
} else {
return View::make('site.about')->with(compact('stats'))->render();
}
}); });
$path = $page ? 'site.about-custom' : 'site.about';
return view($path, compact('page', 'stats'));
} }
public function language() public function language()