Alright so, I've been trying to make it so on the main page (main.blade.php) theres a text saying that there's (this) many users registered. I did the code which is {{ count(Schema::getColumnListing('users')); }}
but it's only counting 9 users even though I got 23 users registered.
CodePudding user response:
getColumnListing()
returns the columns of the table. You should use count()
on a Laravel
model instead.
You already have a user model, from the base Laravel
project. Using that, this will suffice.
{{ User::count(); }}
CodePudding user response:
The getColumnListing('users')
is not what you think it is. You might want to count rows here since you are talking about number of users.
Schema::getColumnListing('users') will return the columns of table i.e., id, username, password
etc, do this instead:
User::count() // this will return the total number of rows