/** * Saved edited page; called viea ajax * @return String */ public function postSavePage() { $okay = true; $page_id = $_REQUEST['page_id']; $page_content = $_REQUEST['thedata']; if ($page_id > 0) { $page = Page::find($page_id); } else { $page = new Page(); $slugify = new Slugify(); $browser_title = $_REQUEST['browser_title']; $page->browser_title = $browser_title; $page->slug = $slugify->slugify($browser_title); // verify that the slug is not already in the db $results = Page::where('slug', $slugify->slugify($browser_title))->get(); foreach ($results as $result) { $okay = false; } } $page->page_content = $page_content; if ($okay) { $page->save(); echo "OK"; } else { echo "Browser title is already in use"; } }
public function updatePost(Request $request, Page $page) { $page->fill($request->all()); $page->meta = $request->get('meta', []); $page->save(); return $this->redirectAction('update', $page); }
public function getInfo(Request $request, Page $page, $class, $function) { $route = $request->route(); $routeInfo = ['path' => $route->getPath()]; $routeInfo = array_merge($routeInfo, $route->getAction()); $out = ['route' => $routeInfo, '__CLASS__' => $class, '__FUNCTION__' => $function, 'page_model' => $page->toArray()]; return $out; }
/** * Run the database seeds. * * @return void */ public function run() { $examplePages = [['path' => '/', 'page_type' => 'basic', 'content' => 'This is the home page content', 'meta' => null], ['path' => 'about', 'page_type' => 'basic', 'content' => 'This is the about page content', 'meta' => null], ['path' => 'services', 'page_type' => 'basic', 'content' => 'This is the services page content', 'meta' => null], ['path' => 'services/marketing', 'page_type' => 'basic', 'content' => 'This is the services marketing page content', 'meta' => null], ['path' => 'services/production', 'page_type' => 'basic', 'content' => 'This is the services production page content', 'meta' => null], ['path' => 'industry/news', 'page_type' => 'articles', 'content' => 'This is the articles page content', 'meta' => ['content_before_list' => 'Content before list', 'content_after_list' => 'Content after list']], ['path' => 'contact-us', 'page_type' => 'contact', 'content' => 'This is the contact page content', 'meta' => null]]; foreach ($examplePages as $pageData) { \App\Models\Page::create($pageData); } }
public function destroy($id) { $page = Page::find($id); //$page->delete(); Notification::success('The page was deleted.'); return Redirect::route('admin.pages.index'); }
/** * @param string $slug * * @return \Illuminate\Http\Response */ public function getPage($slug = null) { if (null === $slug) { $page = $this->page->where('slug', '/')->where('draft', 0)->first(); } else { $page = $this->page->where('slug', $slug)->where('draft', 0)->first(); } if (null === $page) { abort(404); } if (null === $slug) { return view('templates.home', ['page' => $page]); } else { return view('templates.default', ['page' => $page]); } }
public function run() { DB::table('user')->delete(); DB::table('pages')->delete(); Article::create(array('title' => 'First post', 'slug' => 'first-post', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1)); Page::create(array('title' => 'About us', 'slug' => 'about-us', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1)); }
public function run() { $menu = Menu::find()->where(['position' => 'bottom'])->one(); $p = explode(',', $menu->content); $model = Page::find()->where(['id' => $p])->all(); return $this->render('links', ['pages' => $model]); }
public function run() { DB::table('pages')->delete(); for ($i = 0; $i < 10; $i++) { Page::create(['title' => 'Title ' . $i, 'slug' => 'first-page', 'body' => 'Body ' . $i, 'user_id' => 1]); } }
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { $gallery = Page::where('slug', '=', 'gallery')->first(); $images = explode(',', $gallery->content); $images = array_slice($images, 0, 16); return view('frontend.index', ['images' => $images]); }
/** * Show Page. * * @return Response */ public function show($slug) { $page = Page::Where('slug', $slug)->first(); if (!$page) { \App::abort(404); } return view('themes/basic/pages/show', ['page' => $page]); }
/** * Shows page by it's ID * * @param $id * * @return string * @throws \yii\web\NotFoundHttpException */ public function actionShow($id) { $page = Page::loadModel($id, false, false); if ($page === null) { throw new NotFoundHttpException(); } return $this->render('show', ['model' => $page]); }
protected function findModel($id) { if (($model = Page::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Show the application welcome screen to the user. * * @return Response */ public function index($slug) { $page = Page::whereSlug($slug)->first(); if (empty($page)) { die("This page was not found"); //App::abort(404); } return view('front.pages.show', compact('page')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { try { $page = Page::getPageData($this->page)->firstOrFail(); } catch (Exception $e) { return $this->response->errorNotFound(); } return $this->response()->item($page, new PageTransformer())->addMeta('status', 'success')->setStatusCode(200); }
public function pageDelete($id) { try { $page = Page::findOrFail($id); } catch (ModelNotFoundException $e) { return response('Page not found.', 404); } $page->delete(); return redirect()->route('admin.pages.static'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($page = '') { $menuHtml = $this->menuHtml($page); $menuItems = Menu::all(); $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render(); $page = Page::where('key', $page)->first(); $categories = Category::orderBy('sort', 'asc')->get(); $smallCart = $this->smallCart(); return view('page', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'page' => $page, 'categories' => $categories, 'count' => $smallCart['count'], 'sum' => $smallCart['sum']]); }
/** * @param $id * @return \yii\web\Response * @throws NotFoundHttpException * @throws \Exception */ public function actionDelete($id) { /** @var Page $model */ $model = Page::findOne($id); if (!$model) { throw new NotFoundHttpException(); } $model->delete(); return $this->redirect(['list']); }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Page::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]); $query->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Page::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'image_id' => $this->image_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'lang', $this->lang]); return $dataProvider; }
public function search($params) { $query = Page::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description]); return $dataProvider; }
public function __construct() { $this->setting = Settings::getSetting(); View::share('listNewPd', $this->_getNewProduct()); View::share('listNewsTop', $this->_getNewsTop()); View::share('Category', $this->getCategoryShowInIndex()); View::share('menu_provider', $this->getProviderShowInIndex()); View::share('setting', $this->setting); View::share('guideDes', Page::find(4)); View::share('title', ""); }
/** * Show the application dashboard. * * @return Response */ public function show(Request $request) { $stats['categories'] = Category::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['products'] = Product::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['customers'] = User::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['pages'] = Page::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['blogs'] = Blog::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['orders'] = Order::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['revenue'] = Order::where('shop_id', '=', $request->session()->get('shop'))->sum('total'); return view('admin/dashboard', ['stats' => $stats]); }
/** * Show the appropriate view depending on the slug. * * YOU MAY WANT TO MODIFY THIS * Right now it only loads some dummy views. * * @return Response */ public function page($slug) { // get the corresponding page for that slug $page = Page::findBySlugOrId($slug)->withFakes(); // if there is such a page if ($page && $page->translation_lang == \App::getLocale()) { // load the proper template return view('page_templates.' . $page->template, ['page' => $page]); } abort(404); }
public function run() { DB::table('articles')->truncate(); // Using truncate function so all info will be cleared when re-seeding. DB::table('pages')->truncate(); Article::create(array('title' => 'First post', 'slug' => 'first-post', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1, 'created_at' => Carbon\Carbon::now()->subWeek(), 'updated_at' => Carbon\Carbon::now()->subWeek())); Article::create(array('title' => '2nd post', 'slug' => '2nd-post', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1, 'created_at' => Carbon\Carbon::now()->subDay(), 'updated_at' => Carbon\Carbon::now()->subDay())); Article::create(array('title' => 'Third post', 'slug' => 'third-post', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1)); Page::create(array('title' => 'Welcome', 'slug' => 'welcome', 'body' => 'Welcome to the site', 'user_id' => 1)); Page::create(array('title' => 'About us', 'slug' => 'about-us', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1)); Page::create(array('title' => 'Contact', 'slug' => 'contact', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1)); }
/** * Get static page by url * * @param $url * @return mixed */ public function getPage($url) { $page = Page::whereUrl($url)->first(); if (!$page) { throw (new ModelNotFoundException())->setModel(get_class($page)); } else { \Config::set("website.title", $page->title); \Config::set("website.keywords", $page->keywords); \Config::set("website.description", $page->description); return view("pages.page")->withPage($page); } }
/** * A basic test example. * * @return void */ public function testExample() { //$this->assertTrue(true); //Unauthorized access $this->visit('/admin')->seePageIs('login'); //Logging as Admin $admin = User::where('is_admin', '1')->first(); $this->actingAs($admin)->visit('/admin')->seePageIs('admin'); $this->actingAs($admin)->visit('/admin/pages/main')->see('Главная страница'); $this->actingAs($admin)->visit('/admin/pages/main/edit')->see('Редактирование главной страницы'); $this->actingAs($admin)->visit('/admin/pages/static')->see('Статические страницы'); try { //Opening static page editor $static_page = Page::where('id', '>', 1)->firstOrFail(); } catch (ModelNotFoundException $e) { } finally { $this->actingAs($admin)->visit('/admin/pages/static/' . $static_page->id . '/edit')->see('Редактирование страницы'); unset($static_page); } $this->actingAs($admin)->visit('/admin/pages/static')->click('Создать')->see('Создание страницы'); $this->actingAs($admin)->visit('/admin/menu')->see('Редактор меню'); //Create new menu item $this->actingAs($admin)->visit('/admin/menu')->click('Создать')->see('Новый пункт меню')->select(0, 'pid')->type('Тест', 'name')->type('test357', 'url')->press('Создать')->seePageIs('/admin/menu'); try { //Delete created item $menu = Menu::where('url', 'test357')->firstOrFail(); } catch (ModelNotFoundException $e) { } finally { $this->actingAs($admin)->delete('/admin/menu/' . $menu->id); $this->assertResponseStatus(302); $this->assertRedirectedToRoute('admin.menu'); $this->followRedirects()->see('Редактор меню'); unset($menu); } //File manager $this->actingAs($admin)->visit('/admin/files')->see('Файловый менеджер'); //Users $this->actingAs($admin)->visit('/admin/users')->see('Пользователи'); try { //Editing myself $user = User::where('id', $admin->id)->firstOrFail(); } catch (ModelNotFoundException $e) { } finally { $this->actingAs($admin)->visit('/admin/users/' . $admin->id . '/edit')->see('Редактирование пользователя')->press('Обновить')->seePageIs('/admin/users'); unset($user); } //Logout $this->actingAs($admin)->visit('/logout')->seePageIs('/'); //Logging as User $user = User::where('is_admin', '0')->first(); $this->actingAs($user)->get('/admin')->seeStatusCode('403'); $this->actingAs($user)->visit('/logout')->seePageIs('/'); }
/** * Updates an existing Menu model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $pages = Page::find()->all(); if ($model->load(Yii::$app->request->post())) { $menu->content = implode(',', $menu->content); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->render('update', ['model' => $model, 'pages' => $pages]); } }
public function run() { $faker = Faker::create('zh_CN'); $adminUser = User::where('name', '=', 'admin')->first(); $adminUserId = isset($adminUser) ? $adminUser->id : 0; $publicPath = app('path.public'); $dirPath = $publicPath . '/uploads/images/fakers'; $urlDirPath = '/uploads/images/fakers'; DB::table('pages')->delete(); foreach (range(1, 100) as $index) { Page::create(['title' => 'znyesmaxfine单页' . $index, 'thumb' => URL($urlDirPath . '/' . $faker->image($dirPath, 640, 480, null, false)), 'slug' => '', 'content' => $faker->text, 'user_id' => $adminUserId, 'created_at' => new DateTime(), 'updated_at' => new DateTime()]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Page::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'live' => $this->live, 'date_updated' => $this->date_updated, 'date_published' => $this->date_published]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }