传递给Symfony \ Component \ HttpFoundation \ JsonResponse :: __ construct()的参数2必须为整数类型,给定数组,

问题描述 投票:0回答:1

您好,我在laravel中创建了一个资源api,所有其他功能都正常工作,但是get方法无法正常工作:

“参数2传递给Symfony \ Component \ HttpFoundation \ JsonResponse :: __ construct()必须为整数类型,给定数组,在\ vendor \ laravel \ framework \ src \ Illuminate \ Http \ JsonResponse.php在线31“

控制器:

   public function index()
   {
    return response()->json(CountryModel::get(), 200);
    }

  public function store(Request $request)
  {
    $country = Country::create($srequest->all());
    return response()->json($country, 201);
  }

路线

  Route::apiResource('country', 'Country\Country');
laravel eloquent laravel-5.8
1个回答
0
投票

需要传递数组:

© www.soinside.com 2019 - 2024. All rights reserved.