mercredi 12 octobre 2016

Eloquent, combine row columns in where statement

let's say I've got a database containing some films, with the date that they have first been released in a column and the number of months for which I should be showing them in the cinemas in another colum.

What I would like to do is get all the cinemas that are showing any film. I'm trying to condense this in a single query, something like this

 Cinemas::whereHas('films', function($q){
    $q->where('date_created', '>=', \Carbon::now() + showing_months));
 })->get();

showing_months is the number of months for which the film is showing. Is there anyway to access that column in a similar why to which i "access" date_created?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire