/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $blogRecordId = $request->input('blog_record_id'); $br = BlogRecord::findOrFail($blogRecordId); $comments = $br->comments()->orderBy('created_at', 'desc')->get(); return view('blog.comments-list', ['comments' => $comments]); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request) { $id = $request->input('blog_record_id'); $blogRecord = BlogRecord::findOrFail($id); $validator = Validator::make($request->all(), BlogRecordRequest::getValidationRules()); if ($validator->fails()) { $html = view('admin.blog.record-form', ['blogRecord' => $blogRecord, 'method' => 'PATCH', 'url' => action('BlogRecordsController@update')])->withErrors($validator)->render(); return response()->json(['status' => 'retry', 'html' => $html]); } else { $blogRecord->subject = $request->input('subject'); $blogRecord->text = $request->input('text'); $blogRecord->save(); return response()->json(['status' => 'success']); } }