Loading app/Http/Controllers/DivesAPI.php +4 −1 Original line number Diff line number Diff line Loading @@ -3,11 +3,14 @@ namespace App\Http\Controllers; use App\Models\DivingSession; use App\Models\User; class DivesAPI extends Controller { function getDivers($diveID): array { return DivingSession::find($diveID)->getParticipants(); $participants = User::select('*')->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')->where('CAR_REGISTRATION.DS_CODE', $diveID); $participants = $participants->get()->toArray(); return $participants; } } app/Http/Controllers/DivesList.php +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace App\Http\Controllers; use App\Models\DivingGroup; use App\Models\DivingSession; use App\Models\Prerogative; use App\Models\User; Loading app/Models/DivingSession.php +5 −3 Original line number Diff line number Diff line Loading @@ -20,13 +20,15 @@ class DivingSession extends Model use HasFactory; public function getParticipants(): array{ $registrations = DB::table('CAR_REGISTRATION')->where('DS_CODE', $this->DS_CODE)->get(); $registrations = DB::table('CAR_REGISTRATION')->where('DS_CODE', $this->DS_CODE)->first(); $participants = []; foreach($registrations as $registration){ if($registration->REG_ACTIVE === 1){ $participants[] = User::find($registration->US_ID)->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')->where('CAR_REGISTRATION.DS_CODE', $this->DS_CODE)->first(); } $participants = User::find($registration->US_ID)->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')->where('CAR_REGISTRATION.DS_CODE', $this->DS_CODE); $participants = $participants->get()->toArray(); } return $participants; Loading Loading
app/Http/Controllers/DivesAPI.php +4 −1 Original line number Diff line number Diff line Loading @@ -3,11 +3,14 @@ namespace App\Http\Controllers; use App\Models\DivingSession; use App\Models\User; class DivesAPI extends Controller { function getDivers($diveID): array { return DivingSession::find($diveID)->getParticipants(); $participants = User::select('*')->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')->where('CAR_REGISTRATION.DS_CODE', $diveID); $participants = $participants->get()->toArray(); return $participants; } }
app/Http/Controllers/DivesList.php +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace App\Http\Controllers; use App\Models\DivingGroup; use App\Models\DivingSession; use App\Models\Prerogative; use App\Models\User; Loading
app/Models/DivingSession.php +5 −3 Original line number Diff line number Diff line Loading @@ -20,13 +20,15 @@ class DivingSession extends Model use HasFactory; public function getParticipants(): array{ $registrations = DB::table('CAR_REGISTRATION')->where('DS_CODE', $this->DS_CODE)->get(); $registrations = DB::table('CAR_REGISTRATION')->where('DS_CODE', $this->DS_CODE)->first(); $participants = []; foreach($registrations as $registration){ if($registration->REG_ACTIVE === 1){ $participants[] = User::find($registration->US_ID)->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')->where('CAR_REGISTRATION.DS_CODE', $this->DS_CODE)->first(); } $participants = User::find($registration->US_ID)->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')->where('CAR_REGISTRATION.DS_CODE', $this->DS_CODE); $participants = $participants->get()->toArray(); } return $participants; Loading