J
J
Jedi2020-05-20 09:56:41
Laravel
Jedi, 2020-05-20 09:56:41

Has - how about the other way around?

Get those records that do not have records with relationships?

Has helps us to get, for example, a user who has posts. And how to get a user who has no posts?


auth()->user()->posts()
            ->whereNotNull('bg')
            ->has('contents')
            ->get();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2020-05-20
@PHPjedi

Lord helpers! Think before you answer if it's worth it. The author has 400 questions. You, not him, write his project.
PHPjedi for all your questions in the documentation there are answers, just don't be too lazy and open it. Did you find the has()
method somewhere? So why not find the opposite in the same place a little lower?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question