Loading app/Http/Controllers/DivingNumberController.php 0 → 100644 +118 −0 Original line number Diff line number Diff line <?php namespace App\Http\Controllers; use Illuminate\Support\Facades\Auth; use App\Models\DivingNumberModel; use DateTime; use Illuminate\Http\Request; use Illuminate\View\View; class DivingNumberController extends Controller { public function index(): View { $dateDives = DivingNumberModel::join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session','car_registration.ds_code','=','car_diving_session.ds_code') ->where('car_user.US_ID',3) ->get(); $user = Auth::user(); if ($user) { $userId = $user->US_ID; }else{ $userId = 1; } $dives = 99; $usersCount = DivingNumberModel::join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_group', function ($dg) { $dg->on('car_registration.ds_code', '=', 'car_diving_group.ds_code') ->on('car_registration.dg_number', '=', 'car_diving_group.dg_number'); }) ->where('car_user.US_ID', $userId) ->count(); $usersCount = 99 - $usersCount; return view('diveractivities', compact('usersCount'), ['dates' => $dateDives]); } public function allIndex(Request $request): View { if($request['afterthe'] != '' and $request['beforethe'] != ''){ return DivingNumberController::afterAndBefore($request['afterthe'], $request['beforethe']); } if($request['afterthe'] != '' and $request['beforethe'] == ''){ return DivingNumberController::after($request['afterthe']); } if($request['afterthe'] == '' and $request['beforethe'] != ''){ return DivingNumberController::before($request['beforethe']); } $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_group', function ($join) { $join->on('car_registration.ds_code', '=', 'car_diving_group.ds_code') ->on('car_registration.dg_number', '=', 'car_diving_group.dg_number'); }) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } public function afterAndBefore(string $after, string $before): View { $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session', 'car_registration.DS_CODE', '=', 'car_diving_session.DS_CODE') ->where('car_diving_session.DS_DATE', '>=', $after) ->where('car_diving_session.DS_DATE', '<=', $before) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } public function after(string $after): View { $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session', 'car_registration.DS_CODE', '=', 'car_diving_session.DS_CODE') ->where('car_diving_session.DS_DATE', '>=', $after) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } public function before(string $before): View { $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session', 'car_registration.DS_CODE', '=', 'car_diving_session.DS_CODE') ->where('car_diving_session.DS_DATE', '<=', $before) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } } app/Models/DivingNumberModel.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class DivingNumberModel extends Model { protected $table = "CAR_USER"; protected $primaryKey = "US_ID"; protected $type = "int"; use HasFactory; } app/Models/User.php +5 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; class User extends Model { Loading Loading @@ -59,6 +60,10 @@ public function hasRole($roleCode) { return $this->roles->contains('ROL_CODE', $roleCode); } } resources/views/alldiversactivities.blade.php 0 → 100644 +34 −0 Original line number Diff line number Diff line <x-layout> <x-page-title>Plongées réalisées</x-page-title> <form action="?{afterthe}&{beforethe}"> <label for="afterthe">Apres le :</label> <input type="date" name="afterthe"> <label for="before the">et avant le :</label> <input type="date" name="beforethe"> <x-button>Rechercher</x-button> </form> <div class="shadow-md max-w-full w-2/3 content-between rounded-lg overflow-hidden border-2 mx-auto"> <table class="text-sm text-left text-gray-500 w-full"> <thead class="text-xs text-gray-700 uppercase bg-gray-50"> <tr> <th scope="col" class="px-6 py-3">Nom</th> <th scope="col" class="px-6 py-3">Prénom</th> <th scope="col" class="px-6 py-3">Nombre de plongées réalisées</th> </tr> </thead> <tbody> @foreach ($datas as $data) <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $data->US_NAME }}</td> <td class="px-6 py-4">{{ $data->US_FIRST_NAME }}</td> <td class="px-6 py-4">{{ $data->aggregate }}</td> </tr> @endforeach </tbody> </table> </div> </x-layout> No newline at end of file resources/views/diveractivities.blade.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <x-layout> <x-page-title>Historique des plongées</x-page-title> <div class="shadow-md max-w-full w-1/3 rounded-lg overflow-hidden border-2 mx-auto"> <table class="text-sm text-left text-gray-500 w-full"> <thead class="text-xs text-gray-700 uppercase bg-gray-50"> <tr> <th scope="col" class="px-6 py-3">Nombre de plongées</th> </tr> </thead> <tbody> <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $usersCount }}</td> </tr> </tbody> </table> </div> <div class="mt-10 shadow-md max-w-full w-1/3 rounded-lg overflow-hidden border-2 mx-auto"> <table class="text-sm text-left text-gray-500 w-full"> <thead class="text-xs text-gray-700 uppercase bg-gray-50"> <tr> <th scope="col" class="px-6 py-3">Nom</th> <th scope="col" class="px-6 py-3">Prénom</th> <th scope="col" class="px-6 py-3">Date</th> </tr> </thead> <tbody> @foreach($dates as $date) <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $date->US_NAME }}</td> <td class="px-6 py-4">{{ $date->US_FIRST_NAME }}</td> <td class="px-6 py-4">{{ $date->DS_DATE }}</td> </tr> @endforeach </tbody> </table> </div> </x-layout> Loading
app/Http/Controllers/DivingNumberController.php 0 → 100644 +118 −0 Original line number Diff line number Diff line <?php namespace App\Http\Controllers; use Illuminate\Support\Facades\Auth; use App\Models\DivingNumberModel; use DateTime; use Illuminate\Http\Request; use Illuminate\View\View; class DivingNumberController extends Controller { public function index(): View { $dateDives = DivingNumberModel::join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session','car_registration.ds_code','=','car_diving_session.ds_code') ->where('car_user.US_ID',3) ->get(); $user = Auth::user(); if ($user) { $userId = $user->US_ID; }else{ $userId = 1; } $dives = 99; $usersCount = DivingNumberModel::join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_group', function ($dg) { $dg->on('car_registration.ds_code', '=', 'car_diving_group.ds_code') ->on('car_registration.dg_number', '=', 'car_diving_group.dg_number'); }) ->where('car_user.US_ID', $userId) ->count(); $usersCount = 99 - $usersCount; return view('diveractivities', compact('usersCount'), ['dates' => $dateDives]); } public function allIndex(Request $request): View { if($request['afterthe'] != '' and $request['beforethe'] != ''){ return DivingNumberController::afterAndBefore($request['afterthe'], $request['beforethe']); } if($request['afterthe'] != '' and $request['beforethe'] == ''){ return DivingNumberController::after($request['afterthe']); } if($request['afterthe'] == '' and $request['beforethe'] != ''){ return DivingNumberController::before($request['beforethe']); } $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_group', function ($join) { $join->on('car_registration.ds_code', '=', 'car_diving_group.ds_code') ->on('car_registration.dg_number', '=', 'car_diving_group.dg_number'); }) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } public function afterAndBefore(string $after, string $before): View { $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session', 'car_registration.DS_CODE', '=', 'car_diving_session.DS_CODE') ->where('car_diving_session.DS_DATE', '>=', $after) ->where('car_diving_session.DS_DATE', '<=', $before) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } public function after(string $after): View { $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session', 'car_registration.DS_CODE', '=', 'car_diving_session.DS_CODE') ->where('car_diving_session.DS_DATE', '>=', $after) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } public function before(string $before): View { $usersDatas = DivingNumberModel::selectRaw('COUNT(*) as aggregate, car_user.US_FIRST_NAME, car_user.US_NAME') ->join('car_registration', 'car_user.us_id', '=', 'car_registration.us_id') ->join('car_diving_session', 'car_registration.DS_CODE', '=', 'car_diving_session.DS_CODE') ->where('car_diving_session.DS_DATE', '<=', $before) ->groupBy('car_user.us_id', 'car_user.US_NAME', 'car_user.US_FIRST_NAME') ->get(); return view('alldiversactivities', ['datas' => $usersDatas]); } }
app/Models/DivingNumberModel.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class DivingNumberModel extends Model { protected $table = "CAR_USER"; protected $primaryKey = "US_ID"; protected $type = "int"; use HasFactory; }
app/Models/User.php +5 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; class User extends Model { Loading Loading @@ -59,6 +60,10 @@ public function hasRole($roleCode) { return $this->roles->contains('ROL_CODE', $roleCode); } }
resources/views/alldiversactivities.blade.php 0 → 100644 +34 −0 Original line number Diff line number Diff line <x-layout> <x-page-title>Plongées réalisées</x-page-title> <form action="?{afterthe}&{beforethe}"> <label for="afterthe">Apres le :</label> <input type="date" name="afterthe"> <label for="before the">et avant le :</label> <input type="date" name="beforethe"> <x-button>Rechercher</x-button> </form> <div class="shadow-md max-w-full w-2/3 content-between rounded-lg overflow-hidden border-2 mx-auto"> <table class="text-sm text-left text-gray-500 w-full"> <thead class="text-xs text-gray-700 uppercase bg-gray-50"> <tr> <th scope="col" class="px-6 py-3">Nom</th> <th scope="col" class="px-6 py-3">Prénom</th> <th scope="col" class="px-6 py-3">Nombre de plongées réalisées</th> </tr> </thead> <tbody> @foreach ($datas as $data) <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $data->US_NAME }}</td> <td class="px-6 py-4">{{ $data->US_FIRST_NAME }}</td> <td class="px-6 py-4">{{ $data->aggregate }}</td> </tr> @endforeach </tbody> </table> </div> </x-layout> No newline at end of file
resources/views/diveractivities.blade.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <x-layout> <x-page-title>Historique des plongées</x-page-title> <div class="shadow-md max-w-full w-1/3 rounded-lg overflow-hidden border-2 mx-auto"> <table class="text-sm text-left text-gray-500 w-full"> <thead class="text-xs text-gray-700 uppercase bg-gray-50"> <tr> <th scope="col" class="px-6 py-3">Nombre de plongées</th> </tr> </thead> <tbody> <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $usersCount }}</td> </tr> </tbody> </table> </div> <div class="mt-10 shadow-md max-w-full w-1/3 rounded-lg overflow-hidden border-2 mx-auto"> <table class="text-sm text-left text-gray-500 w-full"> <thead class="text-xs text-gray-700 uppercase bg-gray-50"> <tr> <th scope="col" class="px-6 py-3">Nom</th> <th scope="col" class="px-6 py-3">Prénom</th> <th scope="col" class="px-6 py-3">Date</th> </tr> </thead> <tbody> @foreach($dates as $date) <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $date->US_NAME }}</td> <td class="px-6 py-4">{{ $date->US_FIRST_NAME }}</td> <td class="px-6 py-4">{{ $date->DS_DATE }}</td> </tr> @endforeach </tbody> </table> </div> </x-layout>