Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

david2000's avatar

book a seance in advance

I am stuck on two problems:

1)- I have a table named "Course" with 4 fields (date_seance, hour_start, hour_end, fk_bike).

My first problem is that I can not plan dates in advance.

For example, if I reserve a date on 01/09/2019 for the bike 000001.

I must be able to book another booking on 02/09/2019 with the same bike. So, 000001.

public function store(courseRequest $request)
    {
        
        
        $exists = Course::where('date_seance', $request->get('date_seance'))->where('hour_start', $request->get('hour_start'))->where('hour_end', $request->get('hour_end'))->where('fk_bike', $request->get('fk_bike'))->count();

        $date_seance = $request->get('date_seance');

        $conflict = Course::where('fk_bike', $request->get('fk_bike'))->whereDate('date_seance', "<=" , $date_seance)
            ->whereDate('date_seance ', ">=", $date_seance)
            ->first();

        $conflict2 = Course::where('fk_bike', $request->get('fk_bike'))->whereDate('date_seance', "<=" , $ date_seance)->whereDate('date_seance', ">=", $date_seance)->first();


        if(isset($conflict2) || isset($conflict)){
            return redirect()->route('courses.index')
             ->with('error', 'Duplicate ');
        }

        else{
       Course::create($request->all());
            return redirect()->route('courses.index')
                ->with('success', Add !);
        }
       
    }

2)- Second question, if I add a fk_former, do you have an idea of the synthax?

0 likes
5 replies
Snapey's avatar
Snapey
Best Answer
Level 122

sorry, I fail to see where the behaviour of the dropdowns are in any way related to the code you show?

1 like
RoboRobok's avatar

I understand your question, but let me ask you one: isn't it possible to hire the bike 5 minutes before midnight and give it back after midnight, for example?

Please or to participate in this conversation.