Api create request with static variable
Hi there,
I'm creating an API and need to put a parameter with this create request ($id). This id refers to the parent table with the same id.
public function create(Request $request, $id) {
$eigenschap = Eigenschap::create($request->all());
return response()->json($eigenschap);
}
So how can I do that :) ?
public function create(Request $request, $id) {
$request->request->add([
'object_id' => $id
]);
$eigenschap = Eigenschap::create($request->all());
return response()->json($eigenschap);
}
This worked for me :)
Please or to participate in this conversation.