问题
I'm trying to
public function show(Product $product)
{
return ProductDetailResource::collection($product);
}
Call to undefined method App\ Model ::mapInto(), exception: BadMethodCallException file vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php
then google and cant find any results
回答1:
just need to replace
public function show(Product $product)
{
return ProductDetailResource::make($product);
}
instead of:
public function show(Product $product)
{
return ProductDetailResource::collection($product);
}
because collection for $products and collection of product.
but we have one item here
来源:https://stackoverflow.com/questions/62852660/laravel-call-to-undefined-method-app-model-mapinto-vendor-laravel-frame