public function resolve($id) { if (isset($id)) { $complaint = Complaint::find($id); if (isset($complaint)) { $complaint->status = 'Resolved'; $complaint->save(); return json_encode(array('message' => 'done')); } else { return json_encode(array('message' => 'invalid')); } } else { return json_encode(array('message' => 'invalid')); } }