Laravel调用未定义的方法App \\ Model :: mapInto(),vendor \\ laravel \\ framework \\ src \\ Illuminate \\ Support \\ Traits \\ ForwardsCalls.php [英] Laravel Call to undefined method App\\ Model ::mapInto(), vendor\\laravel\\framework\\src\\Illuminate\\Support\\Traits\\ForwardsCalls.php
本文介绍了Laravel调用未定义的方法App \\ Model :: mapInto(),vendor \\ laravel \\ framework \\ src \\ Illuminate \\ Support \\ Traits \\ ForwardsCalls.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试
public function show(Product $product)
{
return ProductDetailResource::collection($product);
}
调用未定义的方法App \ Model :: mapInto(),例外:BadMethodCallException文件vendor \ laravel \ framework \ src \ Illuminate \ Support \ Traits \ ForwardsCalls.php
Call to undefined method App\ Model ::mapInto(), exception: BadMethodCallException file vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php
然后在Google上找不到任何结果
then google and cant find any results
推荐答案
只需要替换
public function show(Product $product)
{
return ProductDetailResource::make($product);
}
代替:
public function show(Product $product)
{
return ProductDetailResource::collection($product);
}
因为要收集$个产品并收集产品.
because collection for $products and collection of product.
但是我们这里有一项
这篇关于Laravel调用未定义的方法App \\ Model :: mapInto(),vendor \\ laravel \\ framework \\ src \\ Illuminate \\ Support \\ Traits \\ ForwardsCalls.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文