lundi 17 octobre 2016

Search in other table?

I have a maintenance table with the following fields: id, car_id, type, and name.

How do I get list of entries from maintenance table where type = 'car wash' but only with model_id = 5?

model_id field are in the car table. Car table with the following fields: id, model_id, engine_size, and color.

How can I use Maintenance::where to get list of entries with matching model_id in a car table? There is car_id in a maintenance table which link with car table.

Do I need to do something like this: ?

  return Maintenance::where('type', 'car_wash')->where(function($query) {
       // get a list a maintenance where model_id = 5 in a car table
  });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire