我有两种模式:
class Parent extends Model {
public function children(){
return $this->hasMany(Child::class);
}
}
class Child extends Model {
public function parent(){
return $this->belongsTo(Parent::class);
}
}
当我运行以下内容时:
$parent = Parent::with(Child::class)->find(1);
我收到以下错误:
Call to undefined method Illuminate\Database\Query\Builder::child()
对此有何想法?