Laravel 5 在数据库查询中合并计数的Laravel

Laravel 5 在数据库查询中合并计数的Laravel,laravel-5,eloquent,Laravel 5,Eloquent,我有两个表、属性和照片,基本代码为 $pr = DB::table('properties') ->leftJoin('photos', 'properties.id', '=', 'photos.property_id') ->select(['properties.id', 'address', 'town', 'postcode', 'units','unitType','examination','priority','completed','quotationRequi

我有两个表、属性和照片,基本代码为

  $pr = DB::table('properties')
->leftJoin('photos', 'properties.id', '=', 'photos.property_id')
->select(['properties.id', 'address', 'town', 'postcode', 'units','unitType','examination','priority','completed','quotationRequired']);
我想计算每个酒店的照片数量,并将其作为noPhotos之类的内容纳入select

我好像被困在这上面了

谢谢

我算出了:

  $pr = DB::table('properties')->leftJoin('photos', 'properties.id', '=', 'photos.property_id')->select(DB::raw('count(photos.id) as photos_count'))->addSelect(['properties.id', 'address', 'town', 'postcode', 'units','unitType','examination','priority','completed','quotationRequired'])->groupBy('properties.id', 'address', 'town', 'postcode', 'units','unitType','examination','priority','completed','quotationRequired')->get();