foreign_key when using create() #67
anchovie91471
started this conversation in
General
Replies: 1 comment 2 replies
-
I had the same issue, I had to change the code. Try something like I did here: Temepest74@788a034 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I may not be understanding the documentation, but when I create a new model with:
$data = $request->validate([
'name' => 'required|string|max:255',
'default' => 'boolean',
'parent_id' => 'integer|nullable',
'team_id' => 'required|integer',
'user_id' => 'required|integer',
]);
$district = District::create($data);
The foreign_key fields in the approvals table is empty. My approvals process using Approval::find($id)->approve() seems to work anyway, but I feel like something is wrong.
I've also tried setting the foreign_key to user_id manually with:
public function getApprovalForeignKeyName(): string
{
return 'author_id';
}
Beta Was this translation helpful? Give feedback.
All reactions