Problems in find () Cakephp

1

Good afternoon, I'm doing find() to check if in the period chosen by the user the feature that he is going to use is available, the only problem I found in him was that if I have an event from 10:00 to 15 : 00 using a dell projector, and another user tries to create another event at 09:00 to 15:00 the same day, it allows the creation of the event. If it tries the same time it shows that the feature is not available, or that it starts after and finishes after it works perfectly it just does not work when the event is before one already registered.

public function getRecursosMesmaData($evento)
{
    $start = $evento['Agenda']['start'];
    $end = $evento['Agenda']['end'];

    $eventos = $this->Agenda->find('all', ['conditions' => ['OR' => ['AND' =>['Agenda.start >=' => $start,'Agenda.start <=' => $end],'AND' =>['Agenda.end >=' => $start,'Agenda.end <=' => $end],]],]);
    if ($eventos) {
        foreach ($eventos as $dado) {
            if ($dado['Agenda']['id_recurso'] == $evento['Agenda']['id_recurso']) {
                return true;
            }
        }
    }
    return false;
}
    
asked by anonymous 10.05.2016 / 20:00

0 answers