In the above both models i commented the method itemDestribution() but still it is working
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This relation displays a Data because of following reasons.
In your
ItemDestributionModel
, You have set relation withUserModel
andItemModel
both.In your
ItemModel
andUserModel
you haven't declare any public function and add Relation Class.
When you call UserModel
it will find hasMany
Relationship in ItemDestributionModel
and user()
function is available with belongsTo
relationship.
That's why laravel fetch data without declaring public function. But you should declare relationship inside public function. :)