public function postComment(Request $request) { $this->validate($request, ['comment' => 'required']); $comment = new TrackComment(); $comment->track_id = $request->track_id; $comment->user_id = Auth::user()->id; $comment->comment = $request->comment; $comment->save(); return redirect('track/view/' . $request->track_id); }
public function postDeleteTrackComment(Request $request) { if (!$request->ajax()) { return response('Bad request', 400); } $comment = App\TrackComment::findOrFail($request->id); $comment->delete(); return response()->json(['status' => true]); }