I am trying to create a duplicate system, I have a form revision with a recording.
For example, I have to change the value of my field hour_start => 18:00
I want to replace by the value => 08:00
When, I validate the form I have an error message:
The value of my field hour start is always the same
In fact, my duplicate system must work for dates, but if I change a value of my field hour_start, it must pass...
public function update(revisionRequest $request, $id)
{
$exists = Revision::where('date_revision_start', $request->get('date_revision_start'))->where('date_revision_end', $request->get('date_revision_end'))->where('hour_start', $request->get('hour_start'))->where('hour_end', $request->get('hour_end'))->where('fk_motorbike', $request->get('fk_motorbike'))->where('fk_garage', $request->get('fk_garage'))->count();
$date_revision_start = $request->get('date_revision_start');
$date_revision_end = $request->get('date_revision_end');
$conflict = Revision::where('fk_motorbike', $request->get('fk_motorbike'))->whereDate('date_revision_start', "<=" , $date_revision_start)
->whereDate('date_revision_end', ">=", $date_revision_start)
->first();
$conflict2 = Revision::where('fk_motorbike', $request->get('fk_motorbike'))->whereDate('date_revision_start', "<=" , $date_revision_end)->whereDate('date_revision_end', ">=", $date_revision_end)->first();
if(isset($conflict2) || isset($conflict)){
return redirect()->route('revisions.index')
->with('error', 'Duplicate date! ');
}
else{
$revisions = Revision::find($id);
$revisions->date_revision_start = $request->get('date_revision_start');
$revisions->date_revision_end = $request->get('date_revision_end');
$revisions->hour_start = $request->get('hour_start');
$revisions->hour_end = $request->get('hour_end');
$revisions->fk_garage = $request->get('fk_garage');
$revisions->fk_motorbike = $request->get('fk_motorbike');
$revisions->save();
return redirect()->route('revisions.index')
->with('success', 'ok')->withInput();
}
}
Thank you for your help.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZIF2bZ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire