“所选项目无效” - NextJS + Laravel / 422 错误

问题描述

我有这个问题... 我创建了一个新的地点记录,然后我检查它是否存在。

enter image description here

到目前为止一切顺利,但是现在当我想将它链接到某个餐厅时,它返回422 错误

enter image description here

我一直在寻找答案,但我不明白我做错了什么。

这是我的代码

    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,'place_id' => 'required|exists:places,],self::$messages);

    $Feeding = Feeding::create($request ->all());
    return response() -> json($Feeding,201); //success
}

我在邮递员中使用的标题

授权:不记名令牌

接受: application/json

有什么解决办法吗? 坦克你

解决方法

好的,我解决了。

我不得不在这里替换:

enter image description here

因为我想链接feeding_places,不链接places 呜呜! ?