zaster

Same Eloquent but different results ? What am i doing wrong

Posted 5 months ago by zaster

I have two views

view no 1

@foreach ($sub_jobs as $sub_job)
    <tr>
          <td{{$sub_job->company->name}}</td>
    </tr>
@endforeach

view no 2

@foreach ($jobs as $job)
                    <tr>                       
                        <td>
                            @foreach ($job->sub_jobs as $sub_job)
                                {{$sub_job->company->name}}
                            @endforeach
                        </td>
                    </tr>
@endforeach

view no 2 gives this error

Trying to get property 'name' of non-object

I did a {{dd($sub_job)}} and both views give the same result

Please sign in or create an account to participate in this conversation.