/** * Display a listing of the resource. * * @return Response */ public function index() { //gets all submitted apps to extract their user ids $applications = SubmittedApplication::all(); $applicants = []; foreach ($applications as $application) { //get biodata and regnumber with user id $applicant = new stdClass(); $biodata = Biodata::find($application->user_id)->toArray(); $reg_num = Scholarship::find($application->user_id)->toArray(); //build applicant object foreach ($biodata as $key => $value) { $applicant->{$key} = $value; } $applicant->reg_num = $reg_num['reg_number']; $applicants[] = $applicant; } return Response::json($applicants, 200); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $userCount = User::all()->count(); $applicantsCount = SubmittedApplication::all()->count(); return Response::json(array("user_count" => $userCount, "applicant_count" => $applicantsCount)); }