Search code examples
phpdatabasehtmllaravel-5laravel-5.3

how do i use this route output to my index page between h3 tags


my web.php

Route::get('/index',function()
{

    $count_total = DB::table('vendors')->count('id');

    return  $count_total;
}); 

in my index.blade.php

<h3>  </h3>

<p>Vendors</p>

Solution

  • Do this

    Route::get('/index',function()
    {
    
        $count_total = DB::table('vendors')->count('id');
    
        return view('index',compact('count_total'));
    }); 
    

    Then In your index.blade.php

    <h3> {{$count_total}} </h3>
    
    <p>Vendors</p>