Answer the question
In order to leave comments, you need to log in
How to load relationships along with deleted records?
There are two models with a one-to-many relationship
class Bonus {
function reward(): BelongsTo {
return $this->belongsTo(Reward::class);
}
function user(): BelongsTo {
return $this->belongsTo(User::class);
}
}
class Reward {
function bonuses(): HasMany {
return $this->hasMany(Bonus::class);
}
}
class User {
function bonuses(): HasMany {
return $this->hasMany(Bonus::class);
}
}
$entries = $user->bonuses()->orderBy(...)
->with('reward')
->paginate();
public function getNameAttribute(): string {
return $this->reward->localizedAttribute('name');
}
Call to a member function localizedAttribute() on null
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question