I have the following models
class ParentModel extends Model
{
public function children()
{
return $this->hasMany('App\Model\Student', 'parent_id');
}
}
class Student extends Model
{
}
When I use ParentModel::find(1)->children
, it gives the correct result. But when I use ParentModel::with('children')->find(1)
, the result array contains a children
key with value as empty array.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1TsJfpV
via IFTTT
Aucun commentaire:
Enregistrer un commentaire