您好,我在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');
需要传递数组: