eloquent laravel: How to get a row count from a ->get()

后端 未结 4 1306
花落未央
花落未央 2021-02-02 05:32

I\'m having a lot of trouble figuring out how to use this collection to count rows.

$wordlist = \\DB::table(\'wordlist\')->where(\'id\', \'<=\', $correcte         


        
4条回答
  •  长情又很酷
    2021-02-02 05:43

    also, you can fetch all data and count in the blade file. for example:

    your code in the controller

    $posts = Post::all();
    return view('post', compact('posts'));
    

    your code in the blade file.

    {{ $posts->count() }}
    

    finally, you can see the total of your posts.

提交回复
热议问题