Search
 
SCRIPT & CODE EXAMPLE
 

PHP

avg rating get in join in laravel 8

$users = User::where('type', 'instructor')->get();
  foreach ($users as $user) {
      $user['ratings'] = $user->ratings()->avg('rate');
  }
  return $users;


$data = User::with('ratings')
->join('Rating table','user.id','=','Rating table.user_id')
->select('user.*',DB::raw('avg(rating_for_user)'))
->get();
Comment

PREVIOUS NEXT
Code Example
Php :: send axios request to php 
Php :: laravel create project with auth 2021 
Php :: laravel use function from another controller 
Php :: get post by name wordpress 
Php :: laravel migration make auto increment 
Php :: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file laravel 
Php :: laravel find many 
Php :: artisan make migration with model 
Php :: laravel query with trashed 
Php :: if browser url is having domain name in it check using php 
Php :: encrypt/decrypt data php 
Php :: how increase php upload size in wordpress 
Php :: create database from migration laravel for all 
Php :: php array remove keys keep values 
Php :: php is defined 
Php :: php echo variable 
Php :: json to php array 
Php :: php ternary shorthand 
Php :: componentes blade laravel attributes merge 
Php :: laravel where multiple values 
Php :: php extract month and year from date 
Php :: php strict mode 
Php :: softdeletes laravel 
Php :: laravel get mysql column datatype 
Php :: php count vs sizeof 
Php :: laravel check if item is in collection 
Php :: drupal 9 modify a views query 
Php :: php variable in echo 
Php :: magento 2.3 check if customer is logged in 
Php :: json encode decode 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =