コード例 #1
0
 public function index()
 {
     if (!isset($_GET['page'])) {
         $_GET['page'] = 1;
     }
     $contents = Cache::remember('contents-' . $_GET['page'], 60, function () {
         $data = Content::orderBy('id', 'desc')->paginate(5);
         $data->setPath('/');
         return $data;
     });
     return view('Site.main', ['contents' => $contents, 'popular' => \App\Layout::popular()]);
 }
コード例 #2
0
ファイル: routes.php プロジェクト: berkcekisbas/belirtileri
Route::group(['domain' => 'www.' . config('settings.domain')], function () {
    Route::get('/', 'Site\\MainController@index');
});
Route::group(['domain' => '{id}.' . config('settings.domain')], function () {
    Route::get('/', function ($id) {
        if (Cache::has($id)) {
            $detail = Cache::get($id);
        } else {
            try {
                $detail = \App\Content::where('seo', $id)->firstOrFail();
                Cache::put($id, $detail, 15);
            } catch (ModelNotFoundException $e) {
                return redirect('/');
            }
        }
        return view('Site.detail', ['content' => $detail, 'popular' => \App\Layout::popular()]);
    });
});
Route::get('/', function () {
    return redirect('http://www.' . config('settings.domain'));
});
/*
Route::group(['middleware' => ['web']], function () {

    Route::get('/', 'Site\MainController@index');

    Route::get('{id}', 'Site\MainController@detail');