Commit 89464f04 authored by cyprien's avatar cyprien
Browse files
parents e6b779a8 be42bd96
Loading
Loading
Loading
Loading
+15 −0
Changes for app/Http/Controllers/HeaderController.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;

class HeaderController extends Controller
{
    function index(): View
    {
        $roles = User::getRole();
        return view('components/header', ['roles' =>$roles]);
    }
}
+1 −1
Changes for app/Http/Middleware/RightChecker.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ class RightChecker
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request, Closure $next): Mixed
    public function handle(Request $request, Closure $next)
    {
        if (!session()->has('user')) {
            abort(401);
+0 −11
Changes for app/Models/User.php: 0 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -45,17 +45,6 @@ public function roles()
        return $this->belongsToMany(Role::class, RoleAttribution::class, 'US_ID', 'ROL_CODE');
    }

    public function getRole() {
        return User::select('CAR_ROLE.ROL_LABEL')
            ->join('CAR_ROLE_ATTRIBUTION', 'CAR_USER.US_ID', '=', 'CAR_ROLE_ATTRIBUTION.US_ID')
            ->join('CAR_ROLE', 'CAR_ROLE_ATTRIBUTION.ROL_CODE', '=', 'CAR_ROLE.ROL_CODE')
            ->where('CAR_USER.US_ID',session('user')->US_ID)
            ->pluck('CAR_ROLE.ROL_LABEL')
            ->first();    }
    
    
    

    /**
     * Check if the user has a given role.
     *
+1 −1
Changes for resources/views/components/header.blade.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class="w-8 h-8 rounded-full py-2 font-bold text-white">{{ substr(session('user')
                    <div class="px-4 py-3">
                        <span
                            class="block text-sm text-white">{{ session('user')->US_FIRST_NAME . " " . session('user')->US_NAME }}</span>
                            <span class="mb-2 mt-2 italic block text-sm truncate text-white">{{ session('user')->getRole() }}</span>
                            <span class="mb-2 mt-2 italic block text-sm truncate text-white">    {{ session('user')->roles()->pluck('ROL_LABEL')->implode(' - ') }}</span>

                            <span class="block text-sm truncate text-gray-400">{{ session('user')->US_EMAIL }}</span>

+6 −0
Changes for resources/views/manageAdherent.blade.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
                        <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>
                        <th scope="col" class="px-6 py-3">Responsable</th>
                        <th scope="col" class="px-6 py-3">Nombre de plongées</th>
                    </tr>
                </thead>
@@ -49,6 +50,11 @@
                                    name="checkbox_{{ $users[0][$i][0] }}_DIR" value="DIR"
                                    @if (array_search('DIR', $users[1][$i]) !== false) checked @endif>
                            </td>
                            <td class="px-6 py-4">
                                <input type="checkbox" id="checkbox{{ $users[0][$i][0] }}"
                                    name="checkbox_{{ $users[0][$i][0] }}_RES" value="RES"
                                    @if (array_search('RES', $users[1][$i]) !== false) checked @endif>
                            </td>
                            <td class="px-6 py-4">
                                {{$usersDives[$i]}}
                            </td>