public function ajax_call_status(Request $request) { $id = $request->id; $status = $request->status; $student = User::find($id); foreach ($student->registers as $register) { $register->call_status = $status; $register->save(); } $telecall = TeleCall::find($request->telecall_id); $telecall->caller_id = $request->caller_id; $telecall->student_id = $id; $telecall->note = $request->note; $telecall->gen_id = Gen::getCurrentGen()->id; $telecall->call_status = $status; $telecall->save(); $total_uncalled = Register::getTotalUncalled(); $total_called = Register::getTotalCalled(); $data = array(); $data['total_uncalled'] = is_numeric($total_uncalled) ? $total_uncalled : 0; $data['total_called'] = is_numeric($total_called) ? $total_called : 0; return json_encode($data); }