mendizalea's avatar

Reusable Eloquent Relationships

Hello, would it be possible to reuse this without having to define these 2 relationships in each model?

public function createdBy(): BelongsTo
{
    return $this->belongsTo(User::class, 'created_by');
}

public function updatedBy(): BelongsTo
{
    return $this->belongsTo(User::class, 'updated_by');
}

Thanks

0 likes
1 reply

Please or to participate in this conversation.