Laravel :: Type error: Too few arguments to function AppProduct::getTax(), 0 passed
I have this code:
public function taxesData(Product $product)
{
$taxes = Auth::user()->taxes;
foreach ($taxes as $tax) {
echo "$product->getTax($tax)";
}
}
which on testing gives this error:
Type error: Too few arguments to function AppProduct::getTax(), 0 passed in E:projectsimsvendorlaravelframeworksrcIlluminateDatabaseEloquentConcernsHasAttributes.php on line 411 and exactly 1 expected
However, just a small change makes it works, but I am not able to understand. Why?
public function taxesData(Product $product)
{
$taxes = Auth::user()->taxes;
foreach ($taxes as $tax) {
echo $product->getTax($tax);
}
}
Please help.
I tried to simplify it for the purpose of posting here… actually i am creating json with html component for a datatable ->
public function taxesData(Product $product)
{
$taxes = Auth::user()->taxes;
return datatables()
->of($taxes)
->addColumn('check',function($tax) use($product){
if($product->hasTax($tax)){
return "<input type='checkbox' class='input-sm row-checkbox' name='tax[$tax->id]' value='$tax->id' checked>";
}else{
return "<input type='checkbox' class='input-sm row-checkbox' name='tax[$tax->id]' value='$tax->id'>";
}
})
->editColumn('tax', function($tax) use($product){
return "<span class='currencyinput form-control'>
<input id='rate' type='text' name='rate' value='$product->getTax($tax)' required autofocus>
</span>"
})
->toJson();
}
from Laravel Questions and Answers https://laravelquestions.com/php/laravel-type-error-too-few-arguments-to-function-appproductgettax-0-passed/
via Lzo Media
No comments:
Post a Comment