1 year ago

Using Queries in Blade Templates

Posted 1 year ago by gouseferoz

Hey Guys,

I am trying to use the queries in the blade template because I have to loop the data using other variable.

@foreach($postCategory as $postcat)
        <li>{{ $postcat}}</li>

{{ $posts= App\Posts::allPosts(postcat) }} //This will give all the posts for that postcategory

    @foreach($posts as $post)
        <h1>{{ $question->created_date}}</h1>


I am not sure if this is a correct method to use.

The issue i am facing is, at the line $posts = App..... , it is not only calling all the data from the DB but also printing on to the page.

Can anyone help me to overcome this or suggest the recommended way to use in my above example.

Thanks in advance :)

Regards, Feroz.

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