/** * List all pages. * * @return Response */ public function index(Request $request) { // pagination $session_type = 'page'; if (!$request->session()->has('order_by')) { $request->session()->put($session_type . '.order_by', 'created_at'); } if (!$request->session()->has('order_dir')) { $request->session()->put($session_type . '.order_dir', 'desc'); } if ($request->order_by) { $request->session()->put($session_type . '.order_by', $request->order_by); } if ($request->order_dir) { $request->session()->put($session_type . '.order_dir', $request->order_dir); } $limit = $request->session()->get('limit'); $orderby = $request->session()->get($session_type . '.order_by') == 'created_at' ? $request->session()->get($session_type . '.order_by') : $request->session()->get('language') . '.' . $request->session()->get($session_type . '.order_by'); $pages = Page::where('shop_id', $request->session()->get('shop'))->where(function ($query) use($request) { if ($request->search) { return $query->where('en.name', 'LIKE', '%' . $request->search . '%'); } })->orderBy($orderby, $request->session()->get($session_type . '.order_dir'))->paginate($limit); $pages->search = $request->search; return view('admin/pages/index', ['pages' => $pages]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $page = Page::where('slug', '=', 'overview')->first(); $gallery = Page::where('slug', '=', 'gallery')->first(); $images = explode(',', $gallery->content); return view('backend.pages.index', ['page' => $page, 'gallery' => $gallery, 'images' => $images]); }
/** * @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]); } }
/** * 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]); }
/** * 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"; } }
/** * 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']]); }
/** * 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]); }
/** * 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('/'); }
public function detail($id) { $page = 'catalog'; $title = Menu::where('key', $page)->value('name'); $menuHtml = $this->menuHtml($page); $menuItems = Menu::all(); $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render(); $pageInfo = Page::where('key', $page)->first(); $categories = Category::orderBy('sort', 'asc')->get(); $product = Product::with(['category', 'color'])->find($id); $product->increment('views'); $recommended = Product::with('category')->take(4)->get(); $smallCart = $this->smallCart(); $cartItem = $this->cartItem($product->id); $page = $product; $page->title = $product->name; return view('site.product', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'title' => $title, 'page' => $page, 'product' => $product, 'categories' => $categories, 'recommended' => $recommended, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'currentItem' => $cartItem, 'currentProductCategory' => $product->category]); }
public function index($page = '') { // $title = Menu::where('key', $page)->value('name'); $categories = Category::orderBy('sort', 'asc')->get(); $menuHtml = $this->menuHtml($page); if (session()->has('cart')) { $cartItems = session()->get('cart'); $sum = $cartItems->sum(); $count = count($cartItems->all()); } else { $sum = 0; $count = 0; } $menuItems = Menu::all(); $products = Product::with('category')->orderBy('views', 'desc')->take(8)->get(); $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render(); $page = Page::where('key', 'index')->first(); return view('index', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'categories' => $categories, 'count' => $count, 'sum' => $sum, 'products' => $products, 'indexFlag' => true, 'page' => $page]); }
public function index($page_url = null) { if (isset($page_url)) { try { $page = Page::where('url', '=', $page_url)->firstOrFail(); } catch (ModelNotFoundException $e) { return view('errors.404'); } if (!$page->keywords || !$page->description) { $main_page = Page::find(1); $page->keywords = $page->keywords ? $page->keywords : $main_page->keywords; $page->description = $page->description ? $page->description : $main_page->description; unset($main_page); } return view('page', ['page' => $page, 'menu' => $this->menu]); } else { return redirect()->route('index'); } }
public function fetch() { $request = Request::path(); if ($request == '/') { $page = Page::where('id', 1)->first(); } else { $page = Page::where('slug', $request)->where('active', 'Yes')->where('publishedDate', '<=', date('Y-m-d H:i:s'))->first(); } if (empty($page)) { return View::make('Error/404')->shares('title', 'Page not found!'); } if (!file_exists(APPDIR . 'Templates/' . $this->template . '/' . $page->layout . '.php')) { $page->layout = 'default'; } $this->layout = $page->layout; $ids = explode(',', $page->sidebars); $leftSidebars = Sidebar::whereIn('id', $ids)->where('position', 'LIKE', '%Left%')->get(); $rightSidebars = Sidebar::whereIn('id', $ids)->where('position', 'LIKE', '%Right%')->get(); return View::make('Default')->shares('title', $page->pageTitle)->shares('browserTitle', $page->browserTitle)->shares('leftSidebars', $leftSidebars)->shares('rightSidebars', $rightSidebars)->shares('pageID', $page->id)->withContent($page->content); }
/** * show generic page. * * @return response */ public function getShowPage() { $browser_title = ''; $page_content = ''; $page_id = 0; // extract page name from the url $uri = explode('/', $_SERVER['REQUEST_URI']); $target = $uri[1]; // find matching page in the db $page = Page::where('slug', '=', $target)->get(); // lookup page content foreach ($page as $item) { $browser_title = $item->browser_title; $page_content = $item->page_content; $page_id = $item->id; } if (strlen($browser_title) == 0) { header('Location: /page-not-found'); exit; } // pass content to some blade template echo $this->blade->render('generic_page', compact('browser_title', 'page_content', 'page_id')); }
public function pathname(Request $request, $pathname) { return Page::where('pathname', '=', $pathname)->firstOrFail(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function putUpdate($id, Request $request) { $rules = array('title' => 'required', 'content' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { //$messages = $validator->messages(); // redirect our user back to the form with the errors from the validator return redirect()->back()->withInput($request->all())->withErrors($validator->messages()); } else { $pagedet = array(); $pagedet['title'] = $request->input('title'); $pagedet['slug'] = Str::slug($request->input('title')); $pagedet['content'] = $request->input('content'); $pagedet['active'] = $request->input('active'); $pagedet['meta_keywords'] = $request->input('meta_keywords'); $pagedet['meta_description'] = $request->input('meta_description'); if (Page::where('id', $id)->update($pagedet)) { $request->session()->flash('alert-success', 'Page content has been updated successfully'); return redirect('admin/pages'); } else { return redirect('admin/pages/edit/' . $id)->withInput(Input::get()); } } }
/** * @param int $type * @param int|null $id * @return string * @throws \Exception */ public static function getPageContent(int $type) { if (!array_key_exists($type, self::getTypes())) { throw new \Exception('Incorrect type given'); } $page = Page::where('type', '=', $type)->first(); if (!$page) { return null; } return $page->getBody(); }
public function pageList() { $pages = Page::where('id', '>', '1')->orderBy('id', 'asc')->get(); return view('admin.pages.pages', ['n' => 0, 'pages' => $pages]); }
public function getWhereSlug($slug) { return Page::where('slug', $slug)->first(); }
public function pages($search = null, $paginate = true) { return Page::where('title', 'like', "%{$search}%")->get(); }
public function gallery() { $gallery = Page::where('slug', '=', 'gallery')->first(); $images = explode(',', $gallery->content); return view('frontend.pages.gallery', ['images' => $images]); }
public static function fetchByKey($key = Null) { return Page::where('slug', $key)->first(); }