Level 12
@panthro The Laravel docs has clear answer for it.
/**
* Get the user that owns the phone.
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'foreign_key', 'owner_key');
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
A producer hasMany productions.
A production belongsTo a role.
Producer:
id | title
Productions:
id | producer_id | production_role_id
Roles:
id | title
Can I get the role with a hasManyThrough on the producer model?
I am aware hasManyThrough is for hasMany relationships, but I cannot remember where I read it but I thought you could swap the argument/keys to make it work like this?
Please or to participate in this conversation.