Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Aronaman's avatar

json 2 table

i am store 2 data base in single controller and use DB::beginTransaction

store is working !

the problem is

public function edit(Organization $organization, BasicOrgInfo $basicOrgInfo)
    {
       return response()->json($organization);
    }

Organization and BasicOrgaInfo HAS one to one relationship! can i pass json ($organization, $basicOrgInfo) like this?

0 likes
2 replies
tykus's avatar

If there is a one-to-one relationship, then the second model should be redundant as far as the Controller action signature (and by extension the route wildcards). You can load the related BasicOrgInfo with the route-model bound Organizations:

public function edit(Organization $organization, BasicOrgInfo $basicOrgInfo)
{
    $organization->load('basic_org_info'); // or whatever is the relation name 
    return response()->json($organization);
}

Please or to participate in this conversation.