apiUrl = config('api.ip_address'); $this->appointmentApiUrl = $this->apiUrl . '/appointments'; $this->studentsApiUrl = $this->apiUrl . '/students'; $this->companiesApiUrl = $this->apiUrl .'/companies'; $this->connectionsApiUrl = $this->apiUrl . '/connections'; $this->messagesApiUrl = $this->apiUrl . '/messages'; $this->diplomasApiUrl = $this->apiUrl . '/diplomas'; } #bottom functions generated by github copilot. Use a student or company object to get the name of the student or company protected function translateStudent($id, $token='') { $student = Http::withHeaders( [ "Authorization" => $token ])->get("{$this->studentsApiUrl}/{$id}")->json('data'); if (isset($student['first_name']) && isset($student['last_name'])) { $id = $student['first_name'] . ' ' . $student['last_name']; } else { $id = '*Verwijderde student*'; } return $id; } protected function translateCompany($id, $token= '') { $company = Http::get("{$this->companiesApiUrl}/{$id}")->json('data'); if (isset($company['name'])) { $id = $company['name']; } else { $id = '*Verwijderd bedrijf*'; } return $id; } protected function translateStudents($array, $students) { foreach ($array as &$value) { foreach ($students as $student) { if ($value['student_id'] == $student['id']) { $value['student_id'] = $student['first_name'] . ' ' . $student['last_name']; break; } } } return $array; } protected function translateCompanies($array, $companies) { foreach ($array as &$value) { foreach ($companies as $company) { if ($value['company_id'] == $company['id']) { $value['company_id'] = $company['name']; break; } } } return $array; } }