mercredi 9 octobre 2019

Laravel incoporating a count in a DB query

I have two tables, properties and photos with a basic code of

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

I would like to count the number of photos to each property and incorporate it into the select as something like noPhotos.

I seem to be stuck on this!

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire