Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TuqueroIvantckJernalyn's avatar

How to add to my Index/Show

I am working on my senior project and struggling with this concept. Maybe it isn't possible, or it is and I'm thinking about it the wrong way.

I currently have this- This displays the student, with all its foreign keys in the other tables. In settings, there is a foreign key 'conversion_id.', I would like settings on the student call(code below) to ALSO display the conversion table, from the FK in settings.

(Code to display students. It shows settings, but not the conversions within settings.)

$student = Student::with('studentIntroSurveys', 'settings', 'giftsSurveyResults', 'studentGiftSurveys', 'devotionals', )->get(); if (!$student) { return response('No Data', 400); } else { return response($student); } '

What it displays

'settings: { setting_id: 4, student_id: 1, dark_mode: 1, conversion_id: 1, notification_enabled: 1, notification_time: "08:00:00" } ''

my has one method

public function settings() { /* Get the settings associated https://azar.pro with the user. */ $settings = $this->hasOne(Settings::class, 'student_id', 'student_id'); return $settings;

0 likes
1 reply

Please or to participate in this conversation.