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

kirchaj's avatar

newbie wrapping head around conversion to laravel

I am working on a "proof of concept" system to show how we can move from a commercial RAD software to laravel. I have been able to get things working on simple models but relationships and where to put some of the code has me scratching my head.

For example, I have a table of students and different tables we use to track different items about each student. Each of these tables is linked by a foreign key (studentid). Here are the questions.

I am trying to reproduce a "student summary" page which displays important pieces from each of these (8 tables). Each of these summary records will have a detail button (like a master detail)

Student
    dispositions
    fieldwork
    admissions.........

So here is my dilemma/confusion. I have created a separate summary.view for the student have pass the student object. i have tested the relationship to the dispositions table in tinker. Do I put the logic of pulling the summary info into each model controller? How do I pull all that info together into the summary view?

I understand when it's a simple 1-1 but I am really talking about multiple 1-many relationships. Any guidance would be appreciated.

Tony

0 likes
6 replies
jlrdw's avatar

There are some free Laracast that covers some of this, you could start there.

kirchaj's avatar

jlrdw,

I appreciate you responding but it is of little help. I have a membership here and actively watch the videos and read the forum. If you have a specific video or series I would love to have you point me that direction.

Otherwise I was hoping for some general guidance on how to attack this topic.

Tony

andy's avatar

Technically, you still can do raw queries. Otherwise, @jlrdw posted the most relevant sections to read and catch up on.

jekinney's avatar

For a database that already exists and trying to use eloquent can be frustrating. Keep in mind though you can explicitly set relationships and fields. Eloquent doesn't care if your db has foreign keys. That is more of effiecent queues in the db side.

In your students model you can use: Public function someItem() { return $this->hasMany(someItem::class, 'studentid', 'if'); }

Sorry on mobile but you see the keys are explicitly set. In your someItem class reverse the relationship with belongsTo(Students::class, 'studentid', 'id');

Please or to participate in this conversation.