Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel get average from a column

$avgStar = Model::avg('star');
Comment

how do we calculate average in laravel 8

{
    $average = collect([1, 5, 9, 5])->avg();
    // Output : 5

    $average = collect([10,20,30])->average();
    // Output : 10
}
Comment

PREVIOUS NEXT
Code Example
Php :: validate laravel 
Php :: print array on php 
Php :: curl in php 
Php :: migrate particular file laravel 
Php :: convert all text in php to uppercase 
Php :: what is scalar data type in php 
Php :: search function using php for database entries 
Php :: php remove path from string url 
Php :: create function parameters php 
Php :: get all laravel validation failed messages 
Php :: laravel check if record exists 
Php :: foreach in php 
Php :: how to use a session in blade 
Php :: wpdb num_rows 
Php :: update query in php 
Php :: php check for null 
Php :: laravel take value from different array by key 
Php :: join multiple tables in laravel eloquent 
Php :: php string slice 
Php :: laravel select only some columns relationship 
Php :: laravel chunk select 
Php :: tinyinteger laravel +size 
Php :: wordpress logout 
Php :: php email attachment and message 
Php :: factory laravel 
Php :: larave Soft Deletes 
Php :: laravel project create with version 
Php :: laravel form old value array 
Php :: laravel carbon set timezone 
Php :: laravel validate datetime with datetime-local 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =