I use the following construction for joining tables: with("attachments", "offers.publisher").
public function publisher()
{
return $this->belongsTo("App\User", "user_id", "id");
}
How to join publisher
relation only when offers.status = 1
?
In other words I need to use publisher
by condition Where
I tried also this:
$announcements = Announcement::whereHas('offers', function($q) {
$q->with("publisher")->where('status', 1);
})->get();