Get list of all users #474
-
New to Shield, but finding my way. I can get a list of users, add new ones and edit users, but am running into a little issue with filtering the list of users. Some of the field below are fields I added and extended the UserModel. If I do this: $users = $this->userModel ->select('users.*')
->where('is_superadmin',0)
->groupBy('users.id')
->orderBy('lname,fname')
->findAll(); I get SQL that looks like this: SELECT `users`.*
FROM `users`
WHERE `is_superadmin` = 0
AND `users`.`deleted_at` IS NULL
GROUP BY `users`.`id`
ORDER BY `lname`, `fname` Where is the users.deleted_at line coming from? I need to do different searches with that on and off, but can't figure out how to override it. TIA |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
UserModel uses soft deletes. So it is necessary unless you want to get deleted users. If you really need to remove it, |
Beta Was this translation helpful? Give feedback.
-
Perfect! Exactly what I was looking for! I have a toggle on the listing page that allows those that have been "deleted" to be shown. |
Beta Was this translation helpful? Give feedback.
UserModel uses soft deletes. So it is necessary unless you want to get deleted users.
See https://codeigniter4.github.io/CodeIgniter4/models/model.html#usesoftdeletes
If you really need to remove it,
you need to extendCodeIgniter\Model
.use
withDeleted()
.