Performance: One-to-one (hasOne, belongsTo)
MEDIUM IMPACT
This affects database query performance and page load speed by controlling how related data is fetched and rendered.
$users = User::with('profile')->get(); foreach ($users as $user) { echo $user->profile->bio; }
foreach ($users as $user) {
echo $user->profile->bio;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Lazy loading one-to-one relation | Minimal DOM nodes | Multiple reflows due to delayed data | Higher paint cost due to slower data | [X] Bad |
| Eager loading one-to-one relation | Minimal DOM nodes | Single reflow after data ready | Lower paint cost with faster data | [OK] Good |