假设我有这个专栏
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模板网!
Laravel Eloquent Union 查询Laravel Eloquent Union query(Laravel Eloquent Union 查询)
覆盖 Laravel 5 辅助函数Overwrite laravel 5 helper function(覆盖 Laravel 5 辅助函数)
laravel querybuilder 如何在 where 函数中使用 likelaravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函数中使用 like)
响应内容必须是实现 __toString()、“boolean"和“The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(响应内容必须是实现 __toS
Laravel 5 的角色,如何只允许管理员访问某些根Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允许管理员访问某些根)
Laravel Auth - 使用 md5 而不是集成的 Hash::make()Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())