Does anyone know why these two ways to count numbers of users in my table give different answers when i run them in tinker?
AppModelsUser::count() => 92269
$count = DB::table(‘users’)->count() => 92829
Running a SQL query in Sequel Pro gives 92829.
Advertisement
Answer
If you have the SoftDelete
trait on your User
model then when you query via the Model it excludes “deleted” entries. You can include them by adding the withTrashed()
constraint.
AppModelsUser::withTrashed()->count();