Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 502
saber tabatabaee yazdi Avatar asked Sep 01 '25 10:09

saber tabatabaee yazdi


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

like image 53
saber tabatabaee yazdi Avatar answered Sep 03 '25 00:09

saber tabatabaee yazdi