收入表有一个保存每月价值的列。在某些月份,该值将为0,但是当我使用以下方法访问该方法时
$服务 - >创收> getMonthTotal(11);
我收到以下错误(public function scopeGetMonthTotal($query, $month)
{
$result = $query->where('month',$month)->sum('value');
return $result;
}
)
这是我使用的范围方法,其中$ result返回0,laravel给我错误。
关于如何为回显值返回0的任何想法?
// Get the file version for the notepad.
FileVersionInfo myFileVersionInfo =
FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\\Notepad.exe");
// Print the product major part number.
textBox1.Text = "Product major part number: " + myFileVersionInfo.ProductMajorPart;
答案 0 :(得分:1)
作为属性访问关系将自动运行get()
,从而导致您的错误。您需要以方法的形式访问您的关系:
$service->income()->getMonthTotal(11);
要查看结果,请务必自己运行get()
:
echo $service->income()->getMonthTotal(11)->get();