Loading app/Exceptions/Handler.php +5 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace App\Exceptions; use Illuminate\Database\QueryException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Http\Request; use Illuminate\Http\Response; Loading Loading @@ -37,6 +38,10 @@ class Handler extends ExceptionHandler */ public function register() { $this->renderable(function(QueryException $queryException, Request $request){ if ($queryException->getCode()==45000) return response()->view('erreur-page',['message'=>$queryException->getMessage()]); }); $this->reportable(function (Throwable $e) { // }); Loading app/Http/Controllers/DiveSessionCreation.php +11 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,9 @@ use Illuminate\Http\Request; use App\Models\DivingSession; use App\Models\DivingLocation; use App\Models\Boat; use Error; class DiveSessionCreation extends Controller { Loading @@ -22,11 +24,17 @@ public static function add($request) $dv->US_ID_CAR_DIRECT = $request->manager; $dv->DS_DATE = $request->day; $dv->CAR_SCHEDULE = $request->hour; $dv->DS_MAX_DEPTH = $request->maxDepth; $dv->DS_MAX_DEPTH = DivingLocation::find($request->location)->DL_DEPTH; $dv->DS_ACTIVE = 1; $dv->DS_MAX_DIVERS = $request->max; $dv->DS_LEVEL = $request->level; 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->DS_LEVEL = 1; $dv->save(); $dv->DS_CODE = 'DS'.sizeof(DivingSession::all()); return $dv; } } app/Http/Controllers/DiveSessionDelete.php 0 → 100644 +18 −0 Original line number Diff line number Diff line <?php namespace App\Http\Controllers; use App\Models\DivingSession; use Illuminate\Http\Request; class DiveSessionDelete extends Controller { // public static function update($id) { $dv = DivingSession::find($id); $dv->DS_ACTIVE = 0; $dv->save(); } } app/Http/Controllers/DiveSessionUpdate.php +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ public static function update($request, $id) $dv->DS_MAX_DEPTH = $request->maxDepth; $dv->DS_ACTIVE = 1; $dv->DS_MAX_DIVERS = $request->max; $dv->DS_LEVEL = $request->level; $dv->PRE_CODE = $request->level; $dv->save(); } } Loading app/Http/Controllers/DivesList.php +6 −2 Original line number Diff line number Diff line Loading @@ -3,15 +3,19 @@ namespace App\Http\Controllers; use App\Models\DivingSession; use App\Models\Prerogative; use App\Models\User; use Error; use Illuminate\View\View; class DivesList extends Controller { function index(): View { $dives = DivingSession::select('DS_CODE', 'CAR_DIVING_SESSION.DL_ID', 'DS_DATE', 'DL_DEPTH', 'CAR_SCHEDULE', 'DL_NAME') $dives = DivingSession::select('DS_CODE', 'CAR_DIVING_SESSION.DL_ID', 'DS_DATE', 'DL_DEPTH', 'CAR_SCHEDULE', 'DL_NAME', 'DS_MAX_DEPTH') ->join('CAR_DIVING_LOCATION', 'CAR_DIVING_SESSION.DL_ID', '=', 'CAR_DIVING_LOCATION.DL_ID') ->get(); return view('dives', ['dives' => $dives]); $user = session()->get('user'); return view('dives', ['dives' => $dives, 'userPre' => Prerogative::find($user->PRE_CODE)]); } } Loading
app/Exceptions/Handler.php +5 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace App\Exceptions; use Illuminate\Database\QueryException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Http\Request; use Illuminate\Http\Response; Loading Loading @@ -37,6 +38,10 @@ class Handler extends ExceptionHandler */ public function register() { $this->renderable(function(QueryException $queryException, Request $request){ if ($queryException->getCode()==45000) return response()->view('erreur-page',['message'=>$queryException->getMessage()]); }); $this->reportable(function (Throwable $e) { // }); Loading
app/Http/Controllers/DiveSessionCreation.php +11 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,9 @@ use Illuminate\Http\Request; use App\Models\DivingSession; use App\Models\DivingLocation; use App\Models\Boat; use Error; class DiveSessionCreation extends Controller { Loading @@ -22,11 +24,17 @@ public static function add($request) $dv->US_ID_CAR_DIRECT = $request->manager; $dv->DS_DATE = $request->day; $dv->CAR_SCHEDULE = $request->hour; $dv->DS_MAX_DEPTH = $request->maxDepth; $dv->DS_MAX_DEPTH = DivingLocation::find($request->location)->DL_DEPTH; $dv->DS_ACTIVE = 1; $dv->DS_MAX_DIVERS = $request->max; $dv->DS_LEVEL = $request->level; 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->DS_LEVEL = 1; $dv->save(); $dv->DS_CODE = 'DS'.sizeof(DivingSession::all()); return $dv; } }
app/Http/Controllers/DiveSessionDelete.php 0 → 100644 +18 −0 Original line number Diff line number Diff line <?php namespace App\Http\Controllers; use App\Models\DivingSession; use Illuminate\Http\Request; class DiveSessionDelete extends Controller { // public static function update($id) { $dv = DivingSession::find($id); $dv->DS_ACTIVE = 0; $dv->save(); } }
app/Http/Controllers/DiveSessionUpdate.php +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ public static function update($request, $id) $dv->DS_MAX_DEPTH = $request->maxDepth; $dv->DS_ACTIVE = 1; $dv->DS_MAX_DIVERS = $request->max; $dv->DS_LEVEL = $request->level; $dv->PRE_CODE = $request->level; $dv->save(); } } Loading
app/Http/Controllers/DivesList.php +6 −2 Original line number Diff line number Diff line Loading @@ -3,15 +3,19 @@ namespace App\Http\Controllers; use App\Models\DivingSession; use App\Models\Prerogative; use App\Models\User; use Error; use Illuminate\View\View; class DivesList extends Controller { function index(): View { $dives = DivingSession::select('DS_CODE', 'CAR_DIVING_SESSION.DL_ID', 'DS_DATE', 'DL_DEPTH', 'CAR_SCHEDULE', 'DL_NAME') $dives = DivingSession::select('DS_CODE', 'CAR_DIVING_SESSION.DL_ID', 'DS_DATE', 'DL_DEPTH', 'CAR_SCHEDULE', 'DL_NAME', 'DS_MAX_DEPTH') ->join('CAR_DIVING_LOCATION', 'CAR_DIVING_SESSION.DL_ID', '=', 'CAR_DIVING_LOCATION.DL_ID') ->get(); return view('dives', ['dives' => $dives]); $user = session()->get('user'); return view('dives', ['dives' => $dives, 'userPre' => Prerogative::find($user->PRE_CODE)]); } }