mardi 3 septembre 2019

date and appointment 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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire