find($report->contract_id); $nohome = NoHome::where('contract_id', $contract->id)->first(); $comments = ReportComment::with('user') ->where('report_id', $id) ->orderBy('created_at', 'asc') ->paginate(50); return view('reports.comments', compact('comments', 'contract', 'nohome', 'report')); } public function store(Request $request, $id) { $validator = Validator::make($request->all(), [ 'comment' => 'required|string', ]); if ($validator->fails()) { return redirect()->back()->withErrors($validator); } $comment = new ReportComment(); $comment->report_id = $id; $comment->user_id = Auth::id(); $comment->comment = strip_tags($request->comment); $comment->save(); return redirect()->back(); } public function destroy($id, $comment_id) { ReportComment::destroy($comment_id); return redirect('reports/' . $id . '/comments'); } }