1
0
Fork 0

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
1 changed files with 34 additions and 16 deletions

View File

@ -2,16 +2,10 @@
namespace App\Http\Controllers; 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 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 class SiteController extends Controller
{ {
@ -47,18 +41,42 @@ class SiteController extends Controller
public function about() public function about()
{ {
$stats = Cache::remember('site:about:stats', 1440, function() { $res = Cache::remember('site:about', 120, function() {
return [ $custom = Page::whereSlug('/site/about')->whereActive(true)->exists();
'posts' => Status::whereLocal(true)->count(), if($custom) {
'users' => User::count(), $stats = Cache::remember('site:about:stats', 60, function() {
'admin' => User::whereIsAdmin(true)->first() return [
]; 'posts' => Status::whereLocal(true)->count(),
'users' => User::count(),
'admin' => User::whereIsAdmin(true)->first()
];
});
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 view('site.about', compact('stats')); return $res;
} }
public function language() public function language()
{ {
return view('site.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'));
}
} }