I'am trying to check if the record has relation and at the same time I want to make an eager load so:
User::has('item')->with('item')->get();
I've noticed that with
method do not check if the record has a relation, is this the right sequence or there are a shorter way to code this?
Just try this:
// Pull all blog users that have
// at least one related model/item
$users = User::has('item')->get();
Instead of this:
User::has('item')->with('item')->get();
Reference on Laravel website.