Count all and get 10 records after where condition in laravel

Created at 30-Aug-2021 , By samar

Count all and get 10 records after where condition in laravel

Through the use of the programming language, we will work together to solve the "Count all and get 10 records after where condition in laravel" puzzle in this lesson.

You can get the count of all records after the where condition and get the specific number of record (10 records) from the table.
  • Count all and get 10 records after where condition in laravel

    $query = $request->get('query');
    $users = User::where('name','like','%'.$query.'%');
    $usersCount = $users->count();
    $users = $users->select('*')->take(10)->get();
    echo $usersCount;
    print_r($users);
    

    This code snippet will help you to get the count of all filltered data and get only 10 records from filttered data.

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.