I am passing a single $order record through to a Blade template, and finding that I cannot access, for example, any order customer attributes, despite them having been included in my query using with() and displaying correctly in a blade dump.
I can't seem to put my finger on what I'm doing wrong here to prevent me from accessing $order->customer->first_name, for example. Any pointers would be hugely appreciated.
The blade dump of {{ $order }} appears like so:
{
  "id": 10,
  "customer": {
    "id": 20,
    "first_name": "John",
    "last_name": "Doe"
  },
  "order_date": "2023-01-10 10:31:51",
  "created_at": "2023-02-11T10:37:05.000000Z",
  ...
}

But any attempt to access $order->customer->first_name results in this 500 response:
Attempt to read property "first_name" on int
$order->customer returns the customer id, which makes sense, but is contrary to what the blade dump would suggest should be the case.
A dd() on the $order variable before sending it to the blade template gives me this output (shortened)
App\Models\Order {#1463 ▼ // app/Http/Controllers/OrderController.php:139
 ...
  #attributes: array:25 [▼
    "id" => 10
    "customer" => 20
    "rfp" => 69
    "order_date" => "2023-01-10 10:31:51"
    "created_at" => "2023-02-11 23:37:05"
    ...
  ]
  #original: array:25 [▶]
  #changes: []
  #casts: array:1 [▶]
  #classCastCache: []
  #attributeCastCache: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: array:4 [▼
    "rfp" => App\Models\User {#1478 ▶}
    "customer" => App\Models\Customer {#1480 ▼
      #connection: "mysql"
      #table: "customers"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      +preventsLazyLoading: false
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #escapeWhenCastingToString: false
      #attributes: array:3 [▼
        "id" => 20
        "first_name" => "John"
        "last_name" => "Doe"
      ]
      #original: array:3 [▶]
      #changes: []
      #casts: array:1 [▶]
      #classCastCache: []
      #attributeCastCache: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      +usesUniqueIds: false
      #hidden: []
      #visible: []
      #fillable: array:17 [▶]
      #guarded: array:1 [▶]
      #searchable: array:9 [▶]
      #forceDeleting: false
    }
    ...
  ]
  ...
}

Web.php
Route::get('/orderpdf/{id}', [OrderController::class, 'generateOrderPDF']);

OrderController.php
public static function generateOrderPDF($id, Request $request) {

        $select = [
            'customer' => function($query) {
                $query->select('id', 'first_name', 'last_name');
            }];
            
        $order = Order::with($select)->find($id);
        
        if (!$order) {
            return response()->json(['message' => 'Order not found.'], 404);
        }

        $pdfHtml = View::make('order-confirmation-pdf', ['order' => $order])->render();

        if ($request->input('preview')) {
            return $pdfHtml;
        }
        
    ... 

Order.php (Model)
public function customer()
    {
        return $this->belongsTo(Customer::class, 'customer');
    }


Customer.php (Model)
public function orders()
    {
        return $this->hasMany(Order::class);
    }