Level 2
what external_id stand for ? yes it will not work because you don't have a foreign key, please specify where is the foreign key or explain what data's shape do you want to get as a result.
I have the following models:
Player: id, external_id, is_emulated, ...
Ban: id, external_id, is_emulated, ...
I tried to append the query with the following code:
public function playerRelation(): BelongsTo
{
return $this->belongsTo(Player::class, 'external_id', 'external_id', fn ($q) => $q->whereColumn('players.is_emulated', 'bans.is_emulated'));
}
It's not working. Nothing changes. If the db has the following records:
Players: 1, "abc", false 2, "abc", true
Bans: 1, "abc", true
The relation finds the 1. player record.
Is it possible to append that query somehow or how do I achieve this relation?
Please or to participate in this conversation.