0
我想在laravel 5.2中使用agencies.organization_id = organizations.id获取具有组织表的外键的代理表。现在用户表也有组织表使用users.organization_id = organizations.id的外键。现在如何获取哪些代理机构与users_id链接的代理机构表。collection to laravel中的字符串5.2查询生成器
public function postagency(Request $request) {
$user_id = $request->user_id;
$org_id = User::where('id', $user_id)->pluck('organization_id')->first();
$postagencies = agency::where('organization_id', $org_id);
echo $postagencies;
}
感谢它的工作..在organization.php中添加一个hasmany()relatioship ... :) –