Open bkrajendra opened 5 years ago
Got it resolved by: in my model I added a custom relation:
public function latestDeviceLog()
{
return $this->hasOne('Myhome\Myplugin\Models\Devicelog')->latest();
}
Now I can access with:
Device::with('latestDeviceLog')->get();
Im currently trying to eager load a relation on main table (Model). By default it eager loads all records on relation. My child relation has many record and I dont want all record to be loaded. Infact i just want to load single last record (latest) record from this relation to be loaded.
is this possible with eager loading.? See my post at SO