Loading app/Http/Controllers/DiveDeletion.php +0 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ class DiveDeletion extends Controller { public static function delete($id) { DiveSessionDelete::update($id); Loading app/Http/Controllers/DiveSessionUpdate.php +5 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\DivingSession; use App\Models\Boat; use Illuminate\Http\Request; class DiveSessionUpdate extends Controller Loading @@ -22,6 +23,10 @@ public static function update($request, $id) $dv->DS_MAX_DEPTH = $request->maxDepth; $dv->DS_ACTIVE = 1; $dv->DS_MAX_DIVERS = $request->max; if(intval($dv->DS_MAX_DIVERS) > Boat::find($request->boat)->BO_NUMBER_OF_SEATS) { return "Le nombre de plongeurs est supérieur au nombre de places du bateau"; } $dv->PRE_CODE = $request->level; $dv->save(); } Loading app/Models/DivingSession.php +13 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace App\Models; use Error; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; Loading Loading @@ -36,10 +37,19 @@ public function getDivingGroups(){ return DivingGroup::where('DS_CODE', $this->DS_CODE)->get(); } public function disable() public static function disable($id) { $this->DS_ACTIVE = 0; $this->save(); $ds = DivingSession::find($id); if(($ds->DS_DATE < date('Y-m-d')) == 1) { return "Impossible de supprimer une plongée passée"; } else { $ds->DS_ACTIVE = 0; $ds->save(); } } public function getRoleForUser(User $user){ Loading resources/views/update_dive.blade.php +10 −3 Original line number Diff line number Diff line Loading @@ -71,8 +71,15 @@ <label for="maxInput">Maximum :</label> </div> <div class="divideFlexBig Column"> <input required type="number" name="min" id="minInput" min="0" placeholder="0" @if (isset($precedent)) <input required type="number" name="max" id="maxInput" min="0" placeholder="0" style="width: 20%;-moz-appearance: textfield;text-align: center;" value="{{ $precedent->DS_MIN_DIVERS }}"> @else <input required type="number" name="max" id="maxInput" min="0" placeholder="0" value="{{$dive->DS_MIN_DIVERS}}" style="width: 20%;-moz-appearance: textfield;text-align: center;"> @endif @if (isset($precedent)) <input required type="number" name="max" id="maxInput" min="0" placeholder="0" style="width: 20%;-moz-appearance: textfield;text-align: center;" Loading Loading @@ -182,6 +189,8 @@ class="clickable block w-full max-w-xs mx-auto bg-yellow-400 hover:bg-yellow-500 focus:bg-yellow-500 text-black rounded-lg px-3 py-3 font-semibold" type="submit" value="Mettre à jour"> </div> </div> </form> <form method="POST" action="/dive/disable/{{$dive->DS_CODE}}"> @csrf <div class="w-full px-3 mb-5"> Loading @@ -191,8 +200,6 @@ class="clickableDelete clickable block w-full max-w-xs mx-auto bg-red-400 hover: </div> </form> </div> </form> </div> <script src="{{ asset('/js/create_div.js') }}"></script> </x-layout> routes/web.php +23 −4 Original line number Diff line number Diff line Loading @@ -155,7 +155,17 @@ * @param $id the code of the diving session */ Route::post('/dive/update/{id}', function ($id, Request $request){ DiveSessionUpdate::update($request, $id); $error = DiveSessionUpdate::update($request, $id); if($error != null) { return view('update_dive', ['dive' => DivingSession::find($id), 'locations' => DivingLocation::all(), 'boats' => Boat::all(), 'levels' => Prerogative::all(), 'users' => User::all(), 'error' => $error]); } return redirect('/'); }); Loading @@ -164,8 +174,18 @@ * @param $id the code of the diving session */ Route::middleware('App\Http\Middleware\RightChecker') ->post('/dive/disable/{id}', function ($id) { DivingSession::find($id)->disable(); ->post('/dive/disable/{id}', function ($id) { $res = DivingSession::disable($id); if($res !== null) { return view('update_dive', ['dive' => DivingSession::find($id), 'locations' => DivingLocation::all(), 'boats' => Boat::all(), 'levels' => Prerogative::all(), 'users' => User::all(), 'error' => $res]); } return redirect('/'); }); Loading @@ -174,7 +194,6 @@ * @param $id the code of the diving session */ Route::post('/dive/delete/{id}', function ($id, Request $request) { DiveDeletion::delete($id); return redirect('/create/dive'); }); Loading Loading
app/Http/Controllers/DiveDeletion.php +0 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ class DiveDeletion extends Controller { public static function delete($id) { DiveSessionDelete::update($id); Loading
app/Http/Controllers/DiveSessionUpdate.php +5 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\DivingSession; use App\Models\Boat; use Illuminate\Http\Request; class DiveSessionUpdate extends Controller Loading @@ -22,6 +23,10 @@ public static function update($request, $id) $dv->DS_MAX_DEPTH = $request->maxDepth; $dv->DS_ACTIVE = 1; $dv->DS_MAX_DIVERS = $request->max; if(intval($dv->DS_MAX_DIVERS) > Boat::find($request->boat)->BO_NUMBER_OF_SEATS) { return "Le nombre de plongeurs est supérieur au nombre de places du bateau"; } $dv->PRE_CODE = $request->level; $dv->save(); } Loading
app/Models/DivingSession.php +13 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace App\Models; use Error; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; Loading Loading @@ -36,10 +37,19 @@ public function getDivingGroups(){ return DivingGroup::where('DS_CODE', $this->DS_CODE)->get(); } public function disable() public static function disable($id) { $this->DS_ACTIVE = 0; $this->save(); $ds = DivingSession::find($id); if(($ds->DS_DATE < date('Y-m-d')) == 1) { return "Impossible de supprimer une plongée passée"; } else { $ds->DS_ACTIVE = 0; $ds->save(); } } public function getRoleForUser(User $user){ Loading
resources/views/update_dive.blade.php +10 −3 Original line number Diff line number Diff line Loading @@ -71,8 +71,15 @@ <label for="maxInput">Maximum :</label> </div> <div class="divideFlexBig Column"> <input required type="number" name="min" id="minInput" min="0" placeholder="0" @if (isset($precedent)) <input required type="number" name="max" id="maxInput" min="0" placeholder="0" style="width: 20%;-moz-appearance: textfield;text-align: center;" value="{{ $precedent->DS_MIN_DIVERS }}"> @else <input required type="number" name="max" id="maxInput" min="0" placeholder="0" value="{{$dive->DS_MIN_DIVERS}}" style="width: 20%;-moz-appearance: textfield;text-align: center;"> @endif @if (isset($precedent)) <input required type="number" name="max" id="maxInput" min="0" placeholder="0" style="width: 20%;-moz-appearance: textfield;text-align: center;" Loading Loading @@ -182,6 +189,8 @@ class="clickable block w-full max-w-xs mx-auto bg-yellow-400 hover:bg-yellow-500 focus:bg-yellow-500 text-black rounded-lg px-3 py-3 font-semibold" type="submit" value="Mettre à jour"> </div> </div> </form> <form method="POST" action="/dive/disable/{{$dive->DS_CODE}}"> @csrf <div class="w-full px-3 mb-5"> Loading @@ -191,8 +200,6 @@ class="clickableDelete clickable block w-full max-w-xs mx-auto bg-red-400 hover: </div> </form> </div> </form> </div> <script src="{{ asset('/js/create_div.js') }}"></script> </x-layout>
routes/web.php +23 −4 Original line number Diff line number Diff line Loading @@ -155,7 +155,17 @@ * @param $id the code of the diving session */ Route::post('/dive/update/{id}', function ($id, Request $request){ DiveSessionUpdate::update($request, $id); $error = DiveSessionUpdate::update($request, $id); if($error != null) { return view('update_dive', ['dive' => DivingSession::find($id), 'locations' => DivingLocation::all(), 'boats' => Boat::all(), 'levels' => Prerogative::all(), 'users' => User::all(), 'error' => $error]); } return redirect('/'); }); Loading @@ -164,8 +174,18 @@ * @param $id the code of the diving session */ Route::middleware('App\Http\Middleware\RightChecker') ->post('/dive/disable/{id}', function ($id) { DivingSession::find($id)->disable(); ->post('/dive/disable/{id}', function ($id) { $res = DivingSession::disable($id); if($res !== null) { return view('update_dive', ['dive' => DivingSession::find($id), 'locations' => DivingLocation::all(), 'boats' => Boat::all(), 'levels' => Prerogative::all(), 'users' => User::all(), 'error' => $res]); } return redirect('/'); }); Loading @@ -174,7 +194,6 @@ * @param $id the code of the diving session */ Route::post('/dive/delete/{id}', function ($id, Request $request) { DiveDeletion::delete($id); return redirect('/create/dive'); }); Loading