Well I have this problem... I have created a new place record, and then I check that it exists.
So far so good, but now when I want to link it to some restaurant, it returns 422 Error.
I was looking for some answer, but I don't understand what I did wrong.
This is my code:
public function store(Request $request){
$this->authorize('create', Feeding::class);
$request->validate([
'date' => 'required|date|max:255',
'food' => 'required|string|max:255',
'observation' => 'required|string',
'quantityLunchs' =>'required|integer',
'user_id' => 'required|exists:users,id',
'artist_id' => 'required|exists:artists,id',
'place_id' => 'required|exists:places,id',
], self::$messages);
$feeding = Feeding::create($request ->all());
return response() -> json($feeding, 201); //success
}
The headers I use in postman:
Authorizaton: Bearer token
Accept: application/json
Any solutions? Tank you