public function getProjects($user_id, $flag) { $arr_prj = Projects::where('user_id', $user_id)->where('project_flag', $flag)->get(); $total = Projects::where('user_id', $user_id)->where('project_flag', $flag)->count(); $arr_msg["MESSAGE"] = "SUCCESS"; $arr_msg["MESSAGE_ARRAY"] = $arr_prj; $arr_msg["STATUS"] = true; $arr_msg["TOTAL"] = $total; echo json_encode($arr_msg); }