Norbertho's avatar

How to exclude users from collection where email address end .test

Hi, I have users table and it contains registered users and also users registered by me. Users registered by me have email address like this: example1@test.test I would like to send email to all users in my database except users registered by me so i would like to exclude users with email addresses ending test. Is there any solution to get all the users from database except with emails ending "test"?

0 likes
2 replies
lostdreamer_nl's avatar
Level 53

How about a simple where query?

$users = User::where('email', 'NOT LIKE', '%@test.test')->get();

Then send emails to those users?

1 like

Please or to participate in this conversation.