Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • eloquent laravel: How to get a row count from a ->get()

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 8.25k
    Comment on it

    count is method which will return an array.It is a query builder. So to count rows from using a ->get() is

    The syntax to count a row a -> get() is

    $wordCount = count($wordlist);
    

    If you have a wordlist model, then you can use Eloquent to get a Collection and then use the Collection's count method.

    Example:

    $wordlist = Wordlist::where('id', '<=', $correctedComparisons)->get();
    $wordCount = $wordlist->count();
    

    By this way we will get a row count from a->get() .

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: