[Vuejs]-How to send a primary key as a foreign key to another table while submitting the form in Laravel vue?

0👍

Something Like this :
but you need to send the data in single request.

public function store(Request $request)
{
    $party = Party::create(party data);
    $corraddress = Corraddress::create(corraddress data + 
        ['party_id' = $party->id]
    );
}

0👍

try this

addNewPost(){
            axios.post('/api/auth/party',{
                full_name: this.full_name,
                ic_passport: this.ic_passport,
                nationality: this.nationality,
                income_tax_no: this.income_tax_no,
                income_Tax_filing_branch: this.income_Tax_filing_branch,
                phone_no: this.phone_no,
                email: this.email,
            }).then(response => {
                axios.post('/api/auth/corraddress',{
                   address_1: this.address_1,
                   address_2: this.address_2,
                   city: this.city,
                   poscode: this.poscode,
                   party_id: response.party.id,
                   // party_id: this.party_id,
            })
    })

},
},

Leave a comment