3
In Laravel, when I want to get data from a table that contains some relationship, or when I want to get the data from a condition of a related table, for example, usuarios
that contains livros
, I use the method has
or whereHas
.
Thus:
Usuario::has('livros')->get();
Or so:
Usuario::whereHas('livros', function ($query)
{
$query->where('titulo', '=', 'Harry Potter');
})->get();
But now I need the reverse situation.
I want to capture only users who don’t have relationships with Livros
.
I want to capture only users who don’t compare relationships with books from Harry Potter
.
How can I do it in the Laravel?
I knew that one
– Miguel Batista