POV
POV

Reputation: 12005

How return data only when relation exist?

I have this query:

$result = Transaction::with("items", "results")->get();

How return data from Transactions only when exist data in relation results?

Upvotes: 0

Views: 49

Answers (1)

hazem ali
hazem ali

Reputation: 301

You may use has method

$result = Transaction::has('results')->with("items", "results")->get();

Upvotes: 4

Related Questions