Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

The result of the hasMany relationship is a collection, so you would need to loop through the listings, displaying the title of each one.

Last updated 2 years ago.
0

In the view or controller? Now i'm confused.

Last updated 2 years ago.
0

In the view. Show your complete view code or at least the one that deals with the deals :)

Last updated 2 years ago.
0

In the view. Do something like

@foreach ($deal->listings as $listing)

{{ $listing->title}}

@endforeach

Apologies for lack of formatting, I'm on an iPhone!

Last updated 2 years ago.
0

Or yeah I see cheers Alex. Got ya!

Also thanks Maks appreciate it, just had a bloody brain freeze, been coding too long today.

Last updated 2 years ago.
0

Done it like this and worked fine for anyone else who encounters the same problem:

@foreach($deals as $deal)
   <h4>Deals for {{ $deal->name }}</h4>
   <div class="container marketing">
        <div class="row">
         @foreach ($deal->listings as $listing)

            <div class="col-lg-4">
                @if ( ! empty($listing->logo))
                    <div class="small-logo"><img src="/uploads/{{ $listing->logo }}"></div>
                @endif

                @if (empty($listing->image))
                    <img src="http://placehold.it/300x200&text=Image Coming Soon">
                @else
                    <img class="img-thumbnail" src="/uploads/{{ $listing->image }}" alt="{{ $listing->title; }}">
                @endif

                <h5>{{ $listing->title; }}</h5>
                <p>{{ $listing->description }}</p>
                <p class="pricing">&pound;{{ $listing->price }}</p>
                <p><a class="btn btn-default" href="http://{{ $listing->url }}" role="button" target="_blank">Get Offer &raquo;</a></p>
            </div><!-- /.col-lg-4 -->
        
    @endforeach
    </div>
 </div>
@endforeach
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

lstables lstables Joined 5 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.