Beispiel #1
0
 public function removeSlider($id)
 {
     $post = Post::find($id);
     $post->featured = false;
     $post->save();
     Flash::success('Artikel telah berhasil dihapus dari slideshow halaman utama.');
     return redirect()->route('dashboard::slider');
 }
Beispiel #2
0
 public function search(Request $request)
 {
     $query = $request->get('q');
     $title = 'Search Results';
     if (\Localization::getCurrentLocale() == 'id') {
         $results = Post::search($query, ['title_id' => 10, 'content_id' => 5])->get();
     } else {
         $results = Post::search($query, ['title_en' => 10, 'content_en' => 5])->get();
     }
     return view('search', compact('title', 'query', 'results'));
 }
Beispiel #3
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure                  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     MainMenu::make('mainmenu', function ($mainmenu) {
         $locale = Localization::getCurrentLocale();
         $daftarmenu = Post::page()->menu()->get()->sortBy('urutan');
         $daftarsubmenu = Post::page()->submenu()->get()->sortBy('urutan');
         $mainmenu->add(trans('trans.home'), route('homepage'));
         foreach ($daftarmenu as $menu) {
             if ($locale == 'id') {
                 if ($menu->link_id) {
                     $submenu = $mainmenu->add($menu->title_id, $menu->link_id);
                 } else {
                     $submenu = $mainmenu->add($menu->title_id, 'id' . '/' . $menu->slug_id);
                 }
                 if ($menu->has_child) {
                     foreach ($daftarsubmenu as $sub) {
                         if ($sub->post_parent == $menu->id) {
                             if ($sub->link_id) {
                                 $submenu->add($sub->title_id, $sub->link_id);
                             } else {
                                 $submenu->add($sub->title_id, 'id' . '/' . $sub->slug_id);
                             }
                         }
                     }
                 }
             } else {
                 if ($menu->link_en) {
                     $submenu = $mainmenu->add($menu->title_en, $menu->link_en);
                 } else {
                     $submenu = $mainmenu->add($menu->title_en, 'en' . '/' . $menu->slug_en);
                 }
                 if ($menu->has_child) {
                     foreach ($daftarsubmenu as $sub) {
                         if ($sub->post_parent == $menu->id) {
                             if ($sub->link_en) {
                                 $submenu->add($sub->title_en, $sub->link_en);
                             } else {
                                 $submenu->add($sub->title_en, 'en' . '/' . $sub->slug_en);
                             }
                         }
                     }
                 }
             }
         }
     });
     return $next($request);
 }
Beispiel #4
0
 public function deletePage($id)
 {
     $page = Post::page()->where('id', '=', $id)->firstOrFail();
     $submenu = Post::page()->where('post_parent', '=', $page->id)->get();
     $page->delete();
     if (count($submenu)) {
         foreach ($submenu as $submenu) {
             $submenu->delete();
         }
     }
     Flash::success('Menu telah berhasil dihapus.');
     return redirect()->route('dashboard::menu');
 }
Beispiel #5
0
 public function editPost($id)
 {
     $title = "Edit Artikel";
     $post = Post::article()->where('id', '=', $id)->firstOrFail();
     return view('article.editPost', compact('title', 'post'));
 }