belongsToMany(PlayerData::class)->withPivot(['progress']); } public function getProgressForPlayer(int $playerDataId): int { $foundProgress = $this->playerData()->where('id', '=', $playerDataId)->first(); if ($foundProgress !== null) return $foundProgress->pivot->progress; // We create challange relation and just return 0 since you cannot have progress for the challenge we just linked. $this->playerData()->attach($playerDataId); return 0; } }