public function graph1Count() { try { //get the count af users accordig to registered dates $graph1 = DB::select(DB::raw('SELECT DATE(reg_date) AS y,COUNT(*) AS item1 FROM patients GROUP BY DATE(reg_date)')); //get the count af doctors accordig to registered dates $graph2 = DB::select(DB::raw('SELECT DATE(reg_date) AS y,COUNT(*) AS item1 FROM doctors GROUP BY DATE(reg_date)')); //get the count af doctors accordig to registered dates and doctor types $graph3 = DB::select(DB::raw('SELECT DATE(reg_date) AS y ,SUM(CASE WHEN doc_type = "FORMAL" THEN 1 ELSE 0 END) AS item1, SUM(CASE WHEN doc_type = "NON_FORMAL" THEN 1 ELSE 0 END) AS item2 FROM doctors GROUP BY DATE(reg_date)')); //get all user count $Patients = Patients::all(); //Get formal doctor count $Formal_doctors = Formal_doctors::all(); //Get non formal doctor count $Non_Formal_doctors = Non_Formal_doctors::all(); //get the number of results in each quary result $graph41 = sizeof($Patients); $graph42 = sizeof($Formal_doctors); $graph43 = sizeof($Non_Formal_doctors); //pass the values through json $res['graph_1'] = $graph1; $res['graph_2'] = $graph2; $res['graph_3'] = $graph3; $res['graph_41'] = $graph41; $res['graph_42'] = $graph42; $res['graph_43'] = $graph43; } catch (Exception $e) { $this->LogError('AdminController Register_Page Function', $e); } return response()->json($res); }