假设我有这个专栏
star
----
1
3
3
1
2
5
3
它有七行并且有整数值!我想让它添加并除以存在的行.
It has seven rows and there are integer values! I want to have it added and divided by the rows there are.
我如何在 Laravel 中做到这一点.我可以用普通的 php 完成,但我想在 Laravel 中学习.
How do I do it in laravel. I can do it in plain php but I want to learn it in laravel.
试试这个:
$avgStar = Model::avg('star');
模型"将替换为您的模型名称
" Model " will replace with your model name
这篇关于如何获得laravel中列值的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!