Search code examples
phplaraveldynamic-data-display

Showing 1 to 10 of 35 entries not working in laravel


I'm working with laravel 5.6 showing data, but it's not working perfectly.

This code displayed me in fist page Showing 0 to 10 of 35 and last page displayed Showing 30 to 40 of 35

$page    = $request->has('page') ? $request->get('page') : 1;
$total   = UserAdmin::count();
$perPage = 10;
$showingTotal  = $page * $perPage;

$currentShowing = $showingTotal>$total ? $total : $showingTotal;
$showingStarted = $showingTotal - $perPage;
$tableInfo = "Showing $showingStarted to $showingTotal of $total";

I want to Showing 1 to 10 of 35 entries in first page and last page will be display Showing 30 to 35 of 35 entries


Solution

  • $tableInfo = "Showing $showingStarted to $currentShowing of $total";
    

    Use specified $showingTotal instead of $currentShowing