Loading app/Models/DivingSession.php +17 −6 Original line number Diff line number Diff line Loading @@ -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; } } app/Models/User.php +5 −0 Original line number Diff line number Diff line Loading @@ -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); Loading resources/views/dives.blade.php +1 −1 Original line number Diff line number Diff line Loading @@ -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> Loading resources/views/divingSessions/showParticipants.blade.php 0 → 100644 +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 routes/web.php +9 −0 Original line number Diff line number Diff line Loading @@ -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() Loading Loading
app/Models/DivingSession.php +17 −6 Original line number Diff line number Diff line Loading @@ -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; } }
app/Models/User.php +5 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
resources/views/dives.blade.php +1 −1 Original line number Diff line number Diff line Loading @@ -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> Loading
resources/views/divingSessions/showParticipants.blade.php 0 → 100644 +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
routes/web.php +9 −0 Original line number Diff line number Diff line Loading @@ -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() Loading