Support the ongoing development of →
Database Laravel
Last updated by @tvbeek 1 year ago.
moderator Solution

Hello @shazam7734

I think it can be helpful to read the documentation about the query builder for more information.

I think this is what you want to have:

$surveys = DB::table('surveys')
    -->select('name', 'value')
    ->where('user_id', $user_id)
    ->orderBy('updated_at', 'DESC')
return view('home',['surveys'=>$surveys]);

PS. I have updated your post to make the codeblocks more readable.

Solution selected by @shazam7734

Thank you so much @tvbeek, that did the trick! I am curious how to create code blocks for making my code more readable :)


@shazam7734 I'm not sure if you can edit your first post to see the change.

But the difference is to use three ` and not one. A single one is for inline code and the use of three is for a block of code and also result in highlighting of the code.

I also place them on a separated line (before and after the code)

shazam7734 liked this reply


Sign in to participate in this thread!


Your banner here too?

Sarah shazam7734 Joined 25 Jul 2022


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

Your logo here?

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

© 2024 - All rights reserved.