Loading app/Http/Controllers/ManageAdherentController.php +21 −1 Original line number Diff line number Diff line Loading @@ -2,10 +2,30 @@ namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; class ManageAdherentController extends Controller { function index() { return view('manageAdherent'); $users = User::select('*')->join('car_role_attribution', 'car_role_attribution.US_ID', '=', 'car_user.US_ID')->orderBy('car_user.US_ID')->get(); $user_role = array(); $oldUserID = null; foreach ($users as $user) { $user_role[$user->US_ID] = [$user->US_ID, [], $user->US_FIRST_NAME . " " . strtoupper($user->US_NAME)]; if ($oldUserID == $user->US_ID) { array_push($user_role[$user->US_ID][1], $user->ROL_CODE); } else { $user_role[$user->US_ID][1] = [$user->ROL_CODE]; } $oldUserID = $user->US_ID; } return view('manageAdherent', ['user_role' => $user_role]); } function update(Request $request) { @dd($request->all()); return redirect()->route('manage_members'); } } resources/views/dashboard.blade.php +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ <hr class="mt-8 mb-4"> <h2 class="text-2xl font-semibold text-gray-800">Responsable</h2> <div class="flex flex-row justify-evenly mt-6 mb-14"> <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer des adhérents" link="#"> <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer des adhérents" link="{{ route('manage_members') }}"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12"> <path stroke-linecap="round" stroke-linejoin="round" d="M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" /> </svg> Loading resources/views/manageAdherent.blade.php +41 −0 Original line number Diff line number Diff line <x-layout> <x-page-title>Gestion des adhérents</x-page-title> <form action="{{ route('updateMembersRole') }}" method="POST"> @csrf <!-- {{ csrf_field() }} --> <div class="shadow-md max-w-full rounded-lg overflow-hidden border-2"> <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">Prénom NOM</th> <th scope="col" class="px-6 py-3">Plongeur</th> <th scope="col" class="px-6 py-3">Sécurité surface</th> <th scope="col" class="px-6 py-3">Pilote</th> <th scope="col" class="px-6 py-3">Directeur de plongée</th> </tr> </thead> <tbody> @foreach ($user_role as $user) <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $user[2] }}</td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_DIV @if(array_search('DIV', $user[1])) checked @endif"> </td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_SEC @if(array_search('SEC', $user[1])) checked @endif"> </td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_PIL @if(array_search('PIL', $user[1])) checked @endif"> </td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_DIR @if(array_search('DIR', $user[1])) checked @endif"> </td> </tr> @endforeach </tbody> </table> </div> <div class="text-right"> <button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mt-4"> Valider </button> </div> </form> </x-layout> routes/web.php +4 −0 Original line number Diff line number Diff line Loading @@ -104,3 +104,7 @@ Route::middleware('App\Http\Middleware\rightChecker') ->get('manage/members', [ManageAdherentController::class, 'index']) ->name('manage_members'); Route::middleware('App\Http\Middleware\rightChecker') ->post('manage/members/roles', [ManageAdherentController::class, 'update']) ->name('updateMembersRole'); Loading
app/Http/Controllers/ManageAdherentController.php +21 −1 Original line number Diff line number Diff line Loading @@ -2,10 +2,30 @@ namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; class ManageAdherentController extends Controller { function index() { return view('manageAdherent'); $users = User::select('*')->join('car_role_attribution', 'car_role_attribution.US_ID', '=', 'car_user.US_ID')->orderBy('car_user.US_ID')->get(); $user_role = array(); $oldUserID = null; foreach ($users as $user) { $user_role[$user->US_ID] = [$user->US_ID, [], $user->US_FIRST_NAME . " " . strtoupper($user->US_NAME)]; if ($oldUserID == $user->US_ID) { array_push($user_role[$user->US_ID][1], $user->ROL_CODE); } else { $user_role[$user->US_ID][1] = [$user->ROL_CODE]; } $oldUserID = $user->US_ID; } return view('manageAdherent', ['user_role' => $user_role]); } function update(Request $request) { @dd($request->all()); return redirect()->route('manage_members'); } }
resources/views/dashboard.blade.php +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ <hr class="mt-8 mb-4"> <h2 class="text-2xl font-semibold text-gray-800">Responsable</h2> <div class="flex flex-row justify-evenly mt-6 mb-14"> <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer des adhérents" link="#"> <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer des adhérents" link="{{ route('manage_members') }}"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12"> <path stroke-linecap="round" stroke-linejoin="round" d="M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" /> </svg> Loading
resources/views/manageAdherent.blade.php +41 −0 Original line number Diff line number Diff line <x-layout> <x-page-title>Gestion des adhérents</x-page-title> <form action="{{ route('updateMembersRole') }}" method="POST"> @csrf <!-- {{ csrf_field() }} --> <div class="shadow-md max-w-full rounded-lg overflow-hidden border-2"> <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">Prénom NOM</th> <th scope="col" class="px-6 py-3">Plongeur</th> <th scope="col" class="px-6 py-3">Sécurité surface</th> <th scope="col" class="px-6 py-3">Pilote</th> <th scope="col" class="px-6 py-3">Directeur de plongée</th> </tr> </thead> <tbody> @foreach ($user_role as $user) <tr class="odd:bg-white even:bg-gray-50 border-b"> <td class="px-6 py-4">{{ $user[2] }}</td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_DIV @if(array_search('DIV', $user[1])) checked @endif"> </td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_SEC @if(array_search('SEC', $user[1])) checked @endif"> </td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_PIL @if(array_search('PIL', $user[1])) checked @endif"> </td> <td class="px-6 py-4"> <input type="checkbox" id="checkbox{{ $user[0] }}" name="checkbox{{ $user[0] }}" value="checkbox{{ $user[0] }}_DIR @if(array_search('DIR', $user[1])) checked @endif"> </td> </tr> @endforeach </tbody> </table> </div> <div class="text-right"> <button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mt-4"> Valider </button> </div> </form> </x-layout>
routes/web.php +4 −0 Original line number Diff line number Diff line Loading @@ -104,3 +104,7 @@ Route::middleware('App\Http\Middleware\rightChecker') ->get('manage/members', [ManageAdherentController::class, 'index']) ->name('manage_members'); Route::middleware('App\Http\Middleware\rightChecker') ->post('manage/members/roles', [ManageAdherentController::class, 'update']) ->name('updateMembersRole');