Laravel Call to undefined method App\\ Model ::mapInto(), vendor\\laravel\\framework\\src\\Illuminate\\Support\\Traits\\ForwardsCalls.php

Viewed 4887

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 Answers

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

Related