我正在设置一个用户仪表板,并希望它显示有多少注册用户。
我尝试了很多东西,但对我没有用。
我在仪表板中的代码:
<h5 class="card-title text-uppercase text-muted mb-0">Registerd Users</h5>
<span class="h2 font-weight-bold mb-0">$usersCount = DB::table('users')
我在用户 Controller 中的代码:
public function index()
users = DB::table('users')->get();
return view('user.index', ['users' => $users]);
最佳答案
你可以使用:
DB::table("users")->count();
或者
App\User::count();
警告:不要使用 php count() 函数 .. 这个函数有问题
关于php - 如何在 Laravel 中显示注册用户数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57084736/