为什么在模板中使用括号调用方法会导致错误,但没有?那么我将如何传递一个参数呢?Laravel:为什么会导致错误 - 调用未定义的方法?
错误:
Call to undefined method Illuminate\Database\Query\Builder::test()
index.blade.php
...
<p class="product-price-old"><s>{{ $product->test("123") }}</s></p>
...
Product.php
...
public function getTestAttribute($value)
{
return $value;
}
...
但如果我做这样的事情,它工作正常:
index.blade.php
...
<p class="product-price-old"><s>{{ $product->test }}</s></p>
...
Product.php
...
public function getTestAttribute()
{
return "123";
}
...