T
T
The Dragger2016-09-22 09:38:36
Algorithms
The Dragger, 2016-09-22 09:38:36

How to select movies for a specified day?

There is such a datepicker on the site, in which the user must select a date and films of this date should be displayed to him (this is already a solved task):
bce8b49f88af48f6b0a8f59a627e911b.png
Base: There is a table films in which there are two fields start_date and end_date . One movie can run from the 21st to the 28th and another can run from the 24th to the 29th. So, on the 28th there will be two movies and on the 29th, 22nd, 21st one, etc.
df9ce61ccb44428d8e12149d97684881.png
And for every day at the same time, it has a scheduled time, the time_film table with the id | start | end | price | films_id .
0f6023987b684faf8c72513acfbb2bac.png
Relationship between films and time_film = OneToMany .
Need ideas on how best to solve this problem. I have ideas in my head like:

$timing_films = Film::where([
            ['status', 0],
            ['end_date', '>=', date('m/d/Y')]
        ])->get();
// достаем все фильмы которые будут играть

This is how to get movies and then sort them on the front-end for each day and display them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-09-22
@IPD2

go through the movies in a loop and build the desired array by date.
example if I understand correctly what the question is about.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question