ordind船长 - 细节Laravel 4
-
21-12-2019 - |
题
早上好,
可以帮助我的人,我需要在父子模型到模型之间创建一条路线,导致父级的ID的URL,它被称为主细节。
我的模型细节库存:
return $this->hasMany('Inventory');
.
我的模型主依赖性:
return $this->belongsTo('Dependence', 'dependece_id', 'id');
.
我想要这样的东西:
localhost:8000 /依赖/ 25 /库存
谢谢你的合作
解决方案
Route::get('dependencies/{id}/inventories', function($dependencyId)
{
$dependency = Dependency::findOrFail($dependencyId);
dd($dependency->integory->toArray());
});
. 不隶属于 StackOverflow