Пример #1
0
 /**
  * @param $slug
  *
  * @return $this
  */
 public function show($slug)
 {
     $page = Page::published()->where('slug', $slug)->first();
     if ($page === null) {
         app()->abort(404, 'page with slug \'' . $slug . '\' not found');
     }
     $this->authorize('show', $page);
     return view('site::page')->with('page', $page);
 }
Пример #2
0
 /**
  * @param FrontendMenuCreated $event
  */
 public function composeFrontendMenu(FrontendMenuCreated $event)
 {
     if (Auth::guest() || !policy(Page::class)->index(Auth::user())) {
         return;
     }
     $event->handler->addChild('site::page.title.index')->setUri('#')->setExtra('icon', 'file-o');
     foreach (Page::published()->get() as $page) {
         $event->handler['site::page.title.index']->addChild($page->slug)->setLabel($page->content->title)->setUri(route('site.show', ['slug' => $page->slug]))->setExtra('raw', true);
     }
 }
Пример #3
0
 public function destroy(Request $request, $id)
 {
     Page::findOrFail($id)->delete();
     return $this->createDefaultResponse($request);
 }
Пример #4
0
 public function run()
 {
     DB::table('site_pages')->delete();
     Page::create(['id' => 1, 'user_id' => 1, 'slug' => 'setup-the-development-environment']);
     Page::create(['id' => 2, 'user_id' => 1, 'slug' => 'project-setup-and-maintenance']);
 }