Answer the question
In order to leave comments, you need to log in
How to make a selection of users through the model, except for users with certain emails (like a black list)?
Good afternoon. There is a selection of all users, then they receive emails. And there is a table of emails (like a blacklist), to which nothing needs to be sent. Is it possible to make eloquent without bicycles so that it selects all users, except for those whose emails are on this black list? If so, how.
Answer the question
In order to leave comments, you need to log in
Adding a relationship to the blacklist table to the User model
public function blackEmail()
{
return $this->hasOne('App\Models\BlackEmail', 'email', 'email');
}
User::doesntHave('blackEmail')
->get();
User::where('has_black_email', false)
->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question