| @@ -62,9 +62,11 @@ | ||
| 62 | 62 | |
| 63 | 63 | $sortCriteria = Arr::get($params, 'sort_criteria', []); |
| 64 | 64 | Sort::make()->apply($query, $sortCriteria); |
| 65 | 65 | |
| 66 | - $with = ['customer']; | |
| 66 | + // product is eager-loaded so the appended display_item_name accessor | |
| 67 | + // resolves the product-prefixed label without an N+1 per row. | |
| 68 | + $with = ['customer', 'product']; | |
| 67 | 69 | |
| 68 | 70 | return $query->with($with) |
| 69 | 71 | ->where(function ($q) use ($searchTerms) { |
| 70 | 72 | $q->where('id', 'LIKE', "%{$searchTerms[0]}%") |
| @@ -105,8 +107,9 @@ | ||
| 105 | 107 | public static function view($id) |
| 106 | 108 | { |
| 107 | 109 | return Subscription::where('id', $id) |
| 108 | 110 | ->with([ |
| 111 | + 'product', | |
| 109 | 112 | 'customer.shipping_address' => function ($query) { |
| 110 | 113 | $query->where('is_primary', 1); |
| 111 | 114 | }, |
| 112 | 115 | 'customer.billing_address' => function ($query) { |