Commit 58e52f4f authored by Julien Ait azzouzene's avatar Julien Ait azzouzene
Browse files

Merge branch 'showParticipants'

parents 68cf9593 79f79811
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);
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
                        <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>
+3 −0
Original line number Diff line number Diff line
@foreach($users as $user)   
<p>{{$user->US_NAME}} {{$user->US_FIRST_NAME}}</p>
@endforeach
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -58,8 +58,17 @@
{
    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('/signup/{ds_code}', [DivingSignUpController::class, 'index']);

Route::get('/signup', [DivingSignUpController::class, 'show'])->name('signup');

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