Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $postable_type = '';
     if ($request->input('type') == 'element') {
         $postable_type = 'subject_elements';
     }
     $post = new CommunityPost();
     $post->fill($request->only('subject', 'content', 'parent_id'));
     $post->postable_id = $request->input('id');
     $post->postable_type = $postable_type;
     $post->owner_type = 'students';
     $post->owner_id = $this->student->id;
     $post->save();
     $post->load('owner', 'replies', 'replies.owner', 'likes');
     return response()->json($post, 200, [], JSON_NUMERIC_CHECK);
 }
Exemplo n.º 2
0
 public function delete_reply($id)
 {
     $post = CommunityPost::findOrFail($id);
     $parent_id = $post->parent_id;
     $post->delete();
     $message = 'تم حذف بنجاح';
     return redirect()->route('community.show', $parent_id)->with('success', $message);
 }