コード例 #1
0
 public function deleteSubtitle($slug)
 {
     if (Subtitle::where('slug', $slug)->exists()) {
         $subtitle = Subtitle::where('slug', $slug)->first();
         $subtitle->delete();
         return Redirect::route('admin.home');
     }
     App::abort(404);
     //TODO: Add Error Message(There is no subtitle found by given subtitle slug)
 }
コード例 #2
0
 public function search()
 {
     $term = Request::input('q');
     $where = Request::input('where');
     $query = null;
     if ($where == "subtitles") {
         $query = Subtitle::where('name', 'like', '%' . $term . '%')->orWhere('description', 'like', '%' . $term . '%')->paginate(30);
     } else {
         $query = Post::where('title', 'like', '%' . $term . '%')->orWhere('content', 'like', '%' . $term . '%')->where('publish', 1)->paginate(30);
     }
     return View::make('search')->with(['query' => $query]);
 }
コード例 #3
0
 public function deletePost($id)
 {
     if (Post::where('id', $id)->exists()) {
         $post = Post::find($id);
         $subtitle = Subtitle::where('id', $post->subtitle_id)->first();
         if ($post->user_id == Auth::user()->id || DB::Table('user_subtitle')->where('subtitle_id', $subtitle->id)->where('user_id', Auth::user()->id)->where('isAdmin', '!=', 0)->exists()) {
             foreach ($post->children()->get() as $children) {
                 $children->destroy($children->id);
             }
             $post->destroy($id);
         }
         return Redirect::back();
     }
     return Redirect::back();
 }
コード例 #4
0
 public function draftPost($slug, $id)
 {
     if (Subtitle::where('slug', $slug)->exists()) {
         $subtitle = Subtitle::where('slug', $slug)->first();
         if (DB::Table('user_subtitle')->where('user_id', Auth::user()->id)->where('subtitle_id', $subtitle->id)->where('isAdmin', '!=', 0)->exists()) {
             if (Post::where('id', $id)->where('publish', 1)->exists()) {
                 $post = Post::where('id', $id)->first();
                 $post->publish = 0;
                 $post->save();
                 return Redirect::route('moderation.home', $slug);
             }
             App::abort(404);
         }
         App::abort(404);
     }
     App::abort(404);
 }