我的web.php
Route::get('/index',function()
{
$count_total = DB::table('vendors')->count('id');
return $count_total;
});
在我的index.blade.php
中<h3> </h3>
<p>Vendors</p>
答案 0 :(得分:0)
试试这个......
Route::get('/', function () {
return view('index', ['count_total' => $count_total]);
});
index.blade.php中的
<h3> {{$count_total}} </h3>
<p>Vendors</p>
答案 1 :(得分:0)
这样做
Route::get('/index',function()
{
$count_total = DB::table('vendors')->count('id');
return view('index',compact('count_total'));
});
然后在你的index.blade.php
中<h3> {{$count_total}} </h3>
<p>Vendors</p>