inRandomOrder()->take(4) won't work

Posted 9 months ago by splendidkeen

I'm currently trying to make my application more dynamic and intelligent. Therefore I wanted to parse partials of content (1) inRandomOrder()->take(x) & (2) inRandomOrder->take(x) + based on specific content (e.g. a city or street) on my home view

This is my setup for case (1)


public function home()
        $businesses = Business::inRandomOrder()->take(4); 
        return view ('home', compact('businesses'));


<div class="col-md-3 col-sm-6 col-xs-12">
    <a href="#"><h4>{{$business->company_name}}</h4></a>
    <a href="#"><p>{{$business->city}}, {{$business->street}}</p></a>



<div class="row" id="genre-display-2"> 
    @each(partials.homeblock', $businesses, 'business')   

But it won't show any businesses, am I missing something?

Thank you

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.