php - Laravel FullCalendar

I am doing a reservation system ... and I am having the following problems:
People can book for example from 11/06/2020 - 10:00 to 11:00 am ... registered this ... the second client cannot register for example from 11/06/2020 - 10:30 to 11:30 (since it is busy) so far everything is perfect ...
Problem 1) But if the reservation is from 11/06/2020 - 10:00 a.m. to 11:00 a.m. ... does not allow a client to register from 11/06/2020 - 11:00 a.m. to 12:00 p.m. ... they must do so from 11/06/2020 - 11:01 a.m. to 12:00 p.m. ...
Problem 2) if a customer registers 11/06/2020 - 11:00 to 12:00
it lets me register 11/06/2020 - 1:00 p.m. to 3:00 p.m. for example but not ...
11/07/2020 - 11:00 to 12:00
He says the schedule is already busy, but he's not comparing the day to me ...
public function validarFecha($fecha, $horaInicial, $horaFinal)
{
$agenda = Booking::select("*")
->whereDate('day', $fecha)
->whereBetween('hour_start', [$horaInicial, $horaFinal])
->orWhereBetween('hour_end', [$horaInicial, $horaFinal])
->first();
return $agenda == null ? true : false;
}
Answer
Answer
Solution:
Just add an additional comparison in your ternary to determine if$horaInicial
matches$agenda->hour_end
where you return false, something like:
return $agenda === null || $agenda->hour_end === $horaInicial
As long as no agenda exists, or the end of the agenda matches the beginning of the agenda, then we will have avalid
start time.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: attempt to read property "id" on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.