Commit b6b15bfa authored by Alenso Lopes's avatar Alenso Lopes
Browse files
parents 008b30e1 40b87e0e
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -5,19 +5,30 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

use Illuminate\Support\Facades\DB;

/**
 * @method static select(string $string, string $string1, string $string2, string $string3, string $string4)
 */
class DivingSession extends Model
{
    protected $table = 'CAR_DIVING_SESSION';
    protected $primaryKey = 'ds_code';
    protected $table = 'car_diving_session';
    protected $primaryKey = 'DS_CODE';
    protected $keyType = 'string';
    public $timestamps = false;

    /*protected $attributes = [
        'DS_CODE' => 'test'
    ];*/

    use HasFactory;

    public function getParticipants(): array{
        $registrations = DB::table('CAR_REGISTRATION')->where('DS_CODE', $this->DS_CODE)->get();
        $participants = [];

        foreach($registrations as $registration){
            if($registration->REG_ACTIVE === 1){
                $participants[] = User::find($registration->US_ID);
            }
        }

        return $participants;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -50,6 +50,11 @@ public function roles()
     * @param string $roleCode the code of the role to check
     * @return bool true if the user has the role, false otherwise
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    protected $keyType = 'int';
    public function hasRole($roleCode)
    {
        return $this->roles->contains('ROL_CODE', $roleCode);
+12 −19
Original line number Diff line number Diff line
<x-layout>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Bree+Serif&family=Space+Grotesk&display=swap" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Bree+Serif&family=Montserrat&family=Space+Grotesk&display=swap" rel="stylesheet">

    <h1 class="text-4xl" style="font-family: 'Space Grotesk', sans-serif; font-weight: bold;">S'inscrire à une plongée</h1>
    <hr style="width: 60%; height: 3px; background-color: black; margin-top: 20px; margin-bottom: 80px;">
    <div class="" style="font-family: 'Montserrat', sans-serif;">
        <table class="">
            <thead class="text-left" style="border-bottom: 2px solid black; font-weight: bold;">
<x-layout>
    <x-page-title>Liste des plongées</x-page-title>
    <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">Date</th>
                <th scope="col" class="px-6 py-3">Plage horaire</th>
@@ -19,19 +12,19 @@
                <th scope="col" class="px-6 py-3">Actions</th>
            </tr>
            </thead>
            <tbody class="">
            <tbody>
            @foreach ($dives as $dive)
                <tr class="">
                    <td class="px-8 py-4">{{ $dive->DS_DATE }}</td>
                    <td class="px-8 py-4">{{ $dive->CAR_SCHEDULE }}</td>
                    <td class="px-8 py-4">{{ $dive->DL_DEPTH }}</td>
                    <td class="px-8 py-4">{{ $dive->DL_NAME }}</td>
                <tr class="odd:bg-white even:bg-gray-50 border-b">
                    <td class="px-6 py-4">{{ $dive->DS_DATE }}</td>
                    <td class="px-6 py-4">{{ $dive->CAR_SCHEDULE }}</td>
                    <td class="px-6 py-4">{{ $dive->DL_DEPTH }}m</td>
                    <td class="px-6 py-4">{{ $dive->DL_NAME }}</td>
                    <td class="px-8 py-4">
                        @if (Session::has('Success'))
                            <div class="alert alert-info">{{ Session::get('Success') }}</div>
                        @endif
                        <a href='/dives/{{$dive->DS_CODE}}' class="bg-green-400 hover:bg-green-500 focus:bg-green-500 text-black rounded-lg px-10 py-1.5">S'inscrire</a>
                        <button class="bg-yellow-400 hover:bg-yellow-500 focus:bg-yellow-500 text-black rounded-lg px-5 py-1.5">Voir les inscrits</button>
                        <a href="/dives/list-divers/{{$dive->DS_CODE}}" class="bg-yellow-400 hover:bg-yellow-500 focus:bg-yellow-500 text-black rounded-lg px-5 py-1.5">Voir les inscrits</a>
                        @if ($errors->any())
                            <div class="alert alert-danger">
                                <ul>
+7 −0
Original line number Diff line number Diff line
@foreach($users as $user)   
<p>{{$user->US_NAME}} {{$user->US_FIRST_NAME}}</p>
@endforeach

<x-button>
    <a href="/dives">Retour à la séance</a>
</x-button>
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
@@ -58,6 +58,13 @@
{
    return view('test', ['user' => User::find(1)]);
});

Route::get('/dives/list-divers/{id}', function($id){
    return view('divingSessions.showParticipants', [
        'users' => DivingSession::find($id)->getParticipants()
    ]);
});

Route::get('/dives/{ds_code}', [DivingSignUpController::class, 'index']);

Route::get('/create/dive', function()