I have a model:
class DistributorContacts extends Model
{
public function contacts()
{
return $this->belongsToMany(Contacts::class);
}
}
I use this like:
$distributors = DistributorContacts::with("contracts")->whereIn("user_id", $this->id)->get();
Problem is that I need to get only one row from "contracts" ordered by date.
How to do that?