public function actionPage($pageslug) { $model = StaticPage::find()->where(["slug" => $pageslug])->asArray()->one(); return $this->render('staticpage', ["data" => $model]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(StaticPage $page) { $page->delete(); Session::flash('message', 'Страница удалена'); return redirect()->route('admin.page.index'); }
/** * Finds the StaticPage model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return StaticPage the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = StaticPage::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
Route::resource('comments', 'CommentsController'); //-> $router->bind('comments', function ($ads_id) { return \App\Models\Comments::where('ads_id', 21)->first(); }); /** * Services */ Route::resource('services', 'ServicesController'); /** * * Static page */ $router->get('/page/{spage}', ['uses' => 'StaticPageController@index', 'as' => 'static-page']); $router->bind('spage', function ($slug) { return \App\Models\StaticPage::where('slug', '=', $slug)->firstOrFail(); }); /** * * Gallery */ $router->get('/gallery/{gslug}', ['uses' => 'GalleryController@index', 'as' => 'gallery.index']); $router->bind('gslug', function ($slug) { return \App\Models\Gallery::where('slug', '=', $slug)->firstOrFail(); }); /** ADMIN */ $router->get('/admin', function () { return \Illuminate\Support\Facades\Redirect::route('admin.dashboard.index'); }); $router->bind('banner', function ($id) { return App\Models\Banner::find($id);
public function actionStatic($action) { $page = StaticPage::findOne(['pagekey' => $action, 'enabled' => 1]); $view = file_exists($this->viewPath . DIRECTORY_SEPARATOR . $action . '.php') ? $action : 'static'; return $this->render($view, ['page' => $page]); }