@code_chris sorry for the delay, was traveling the last 36 hours ;(. So I was planning on having multiple Step entries per job since there may be additional items that need to be done per job. Maybe to keep things simpler I will just do a 1-to-1, or drop everything into 1 table lol, but I'm really trying to grasp the concept of how this works. I read an article only about how you should create multiple tables for your database so you can easily add more columns to those tables later down the road without suffering horrible DB query performance
So for the table attached you can see the following:
- There can be many jobs
- A job can only have one customer
- A job can have many steps
- A job can have many poles
- A job can have many permits

The numbers shown in the last 2 columns are just placeholders till I can get the data to display. Based on your code, I think my for loop would look like this
@foreach($jobs as $job)
<tr>
<td>{{ $job->number }}</td>
<td>{{ $job->customer->name }}</td>
@foreach($steps->steps as $step)
<td>{{ $step->body }}</td>
@endforeach
@foreach($poles->poles as $pole)
<td>{{ $pole->njuns_ticket }}</td>
@endforeach
@foreach($permit->permits as $permit)
<td>{{ $permit->number }}</td>
@endforeach
</tr>
@endforeach
Here's what I tested but failed with my controller. There's nothing fancy about this, i'm just trying to get some data from each (relation) table column and show what job it's tied too:
public function index()
{
$jobs = Job::all();
$permits = Permit::all();
$poles = Pole::all();
$steps = Step::all();
return view('jobs.home', compact ('jobs', 'permits', 'poles', 'steps'));
}
To put things in perspective here's the schema so far
