Loading app/Models/DivingSession.php +16 −5 Original line number Diff line number Diff line Loading @@ -5,16 +5,27 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; class DivingSession extends Model { protected $table = 'car_diving_session'; protected $primaryKey = 'ds_code'; 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 +6 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,10 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; protected $table = 'car_user'; protected $primaryKey = 'US_ID'; protected $keyType = 'int'; } 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 +8 −0 Original line number Diff line number Diff line <?php use App\Models\DivingSession; use Illuminate\Support\Facades\Route; /* Loading @@ -16,3 +17,10 @@ Route::get('/', function () { return view('welcome'); }); Route::get('/plongees/{id}', function($id){ $divingSession = DivingSession::find($id); return view('divingSessions.showParticipants',[ 'users' => $divingSession->getParticipants() ]); }); Loading
app/Models/DivingSession.php +16 −5 Original line number Diff line number Diff line Loading @@ -5,16 +5,27 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; class DivingSession extends Model { protected $table = 'car_diving_session'; protected $primaryKey = 'ds_code'; 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 +6 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,10 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; protected $table = 'car_user'; protected $primaryKey = 'US_ID'; protected $keyType = 'int'; }
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 +8 −0 Original line number Diff line number Diff line <?php use App\Models\DivingSession; use Illuminate\Support\Facades\Route; /* Loading @@ -16,3 +17,10 @@ Route::get('/', function () { return view('welcome'); }); Route::get('/plongees/{id}', function($id){ $divingSession = DivingSession::find($id); return view('divingSessions.showParticipants',[ 'users' => $divingSession->getParticipants() ]); });