Update SiteController

This commit is contained in:
Daniel Supernault 2019-02-05 13:58:48 -07:00
parent 14be898431
commit 326a1b353a
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2,16 +2,10 @@
namespace App\Http\Controllers;
use App;
use App\Follower;
use App\Profile;
use App\Status;
use App\User;
use App\UserFilter;
use App\Util\Lexer\PrettyNumber;
use Auth;
use Cache;
use Illuminate\Http\Request;
use App, Auth, Cache, View;
use App\Util\Lexer\PrettyNumber;
use App\{Follower, Page, Profile, Status, User, UserFilter};
class SiteController extends Controller
{
@ -47,18 +41,42 @@ class SiteController extends Controller
public function about()
{
$stats = Cache::remember('site:about:stats', 1440, function() {
$res = Cache::remember('site:about', 120, function() {
$custom = Page::whereSlug('/site/about')->whereActive(true)->exists();
if($custom) {
$stats = Cache::remember('site:about:stats', 60, function() {
return [
'posts' => Status::whereLocal(true)->count(),
'users' => User::count(),
'admin' => User::whereIsAdmin(true)->first()
];
});
return view('site.about', compact('stats'));
return View::make('site.about')->with('stats', $stats)->render();
} else {
$stats = Cache::remember('site:about:stats', 60, function() {
return [
'posts' => Status::whereLocal(true)->count(),
'users' => User::count(),
'admin' => User::whereIsAdmin(true)->first()
];
});
//return view('site.about', compact('stats'));
return View::make('site.about')->with('stats', $stats)->render();
}
});
return $res;
}
public function language()
{
return view('site.language');
}
public function communityGuidelines(Request $request)
{
$slug = '/site/kb/community-guidelines';
$page = Page::whereSlug($slug)->whereActive(true)->first();
return view('site.help.community-guidelines', compact('page'));
}
}