예제 #1
0
 /**
  * Display the specified content.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $content = Content::findOrFail($id);
     $uploader = User::find($content->user_id);
     $comments = Comment::all()->where('content_id', '=', $id);
     return view('content.detail', compact('content', 'uploader', 'comments'));
 }
예제 #2
0
 public function destroy($id)
 {
     $content = Content::findOrFail($id);
     $this->authorize('manage-course-contents', $content->course);
     $content->delete();
     session()->flash('success', 'El contenido se ha editado.');
     return redirect()->route('course.show', $content->course->id);
 }
예제 #3
0
 /**
  * Delete a Topic
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $Topic = $this->Topic->findOrFail($id);
     if ($Topic->delete()) {
         Flash::success(trans('app.Successful operation'));
         return redirect()->route('topic.index');
     } else {
         Flash::error(trans('app.Operation failed'));
         return redirect()->back();
     }
 }
 public function updateContent($id, Request $request)
 {
     $content = Content::findOrFail($id);
     $content->update(['title' => $request->title, 'isvisible' => $request->isvisible, 'isfeatured' => $request->isfeatured]);
     if ($request->input('tag_list') == "") {
         $content->tags()->detach($request->input('tag_list'));
     } else {
         $content->tags()->sync($request->input('tag_list'));
     }
     return redirect('/adminPanel/contentMaintenance');
 }
예제 #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $request->merge(['body' => Purifier::clean($request->input('body'), 'ugc')]);
     // validate
     $this->validate($request, ['entity_id' => ['required', 'integer'], 'body' => ['required', 'min:25']]);
     $Entity = Content::findOrFail($request->id);
     $this->Comment->body = $request->input('body');
     $this->Comment->user_id = Auth::user()->id;
     $this->Comment->type_id = $Entity->type_id;
     $this->Comment->entity_id = $request->input('entity_id');
     if ($this->Comment->save()) {
         event(new \App\Events\ContentWasCommented($this->Comment));
         Flash::success(trans('app.Successful operation'));
         return redirect()->back();
     } else {
         Flash::error(trans('app.Operation failed'));
         $request->flash();
         return redirect()->back()->withErrors($this->Comment->validator);
     }
 }
예제 #6
0
 /**
  * The content vote
  *
  * @param string $contentId
  * @param string $voteType
  * @param string $route
  *
  * @return Response
  */
 public function getVote($contentId, $voteType, $route)
 {
     $Content = Content::findOrFail($contentId);
     $ContentVote = (new ContentVote())->where(['entity_Id' => $contentId, 'user_id' => Auth::user()->id])->first();
     //
     if ($voteType === 'vote_up') {
         if ($ContentVote) {
             if ($ContentVote->value !== ContentVote::VALUE_UP) {
                 $ContentVote->value = ContentVote::VALUE_UP;
                 $ret = $ContentVote->save();
                 event(new \App\Events\ContentWasVote($Content, 'vote_up_changed'));
             }
         } else {
             $ContentVote = new ContentVote();
             $ContentVote->user_id = Auth::user()->id;
             $ContentVote->entity_id = $contentId;
             $ContentVote->value = ContentVote::VALUE_UP;
             $ret = $ContentVote->save();
             event(new \App\Events\ContentWasVote($Content, 'vote_up'));
         }
         //
     } else {
         if ($voteType === 'vote_up_cancel') {
             $ret = $ContentVote->delete();
             event(new \App\Events\ContentWasVote($Content, 'vote_up_cancel'));
             //
         } else {
             if ($voteType === 'vote_down') {
                 if ($ContentVote) {
                     if ($ContentVote->value !== ContentVote::VALUE_DOWN) {
                         $ContentVote->value = ContentVote::VALUE_DOWN;
                         $ret = $ContentVote->save();
                         event(new \App\Events\ContentWasVote($Content, 'vote_down_changed'));
                     }
                 } else {
                     $ContentVote = new ContentVote();
                     $ContentVote->user_id = Auth::user()->id;
                     $ContentVote->entity_id = $contentId;
                     $ContentVote->value = ContentVote::VALUE_DOWN;
                     $ret = $ContentVote->save();
                     event(new \App\Events\ContentWasVote($Content, 'vote_down'));
                 }
                 //
             } else {
                 if ($voteType === 'vote_down_cancel') {
                     $ret = $ContentVote->delete();
                     event(new \App\Events\ContentWasVote($Content, 'vote_down_cancel'));
                 }
             }
         }
     }
     if (isset($ret) && $ret) {
         Flash::success(trans('app.Successful operation'));
         return redirect()->route($route, ['id' => $contentId]);
     } else {
         Flash::error(trans('app.Operation failed'));
         return redirect()->route($route, ['id' => $contentId]);
     }
 }
예제 #7
0
 /**
  * Display the specified content.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $content = Content::findOrFail($id);
     return view('content.detail', compact('content'));
 }
예제 #8
0
 public function updateContent(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'content' => 'required', 'category_id' => 'required|numeric', 'status' => 'required']);
     $content = Content::findOrFail($request->input('id'));
     $content->updatedBy()->associate(Auth::user());
     $content->thumb_images = $request->input('images');
     $content->thumb_images = str_replace('source', 'thumbs', $content->thumb_images);
     $content->update($request->all());
     Session::flash('flash_message', 'Content successfully updated!');
     return redirect()->back();
 }
예제 #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $post = Content::findOrFail($id);
     $post->delete();
 }