0👍
You receive a 500 error because the column party_id
is not nullable, and so the insert in database fails.
You always have to send it when creating a new corraddress or you can set it as nullable
$table->unsignedBigInteger('party_id')->nullable();
I suggest you a more elegant way to define that foreign id:
$table->foreignId('party_id')
->nullable()
->constrained('parties')
->cascadeOnDelete()
->cascadeOnUpdate();
Another suggestion is to set in the .env file
APP_DEBUG=true
To receive more details from laravel when an error occurs.
EDIT:
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
})
}
Sorry I’m not so used with axios
Source:stackexchange.com