Laravel Pivot Tables Help

Hi All

Working in Laravel 5.8.

I’m trying to figure out this pivot table scenario with orders and products and i think i’ve got it sussed. Except the fact that i cant insert data into the tables due to Call to a member function products() on null.

I have a pivot table called order_product of which has the columns order_id & product_id.

In my models i have:

Order model: belongsToMany products

public function products()
    {
        return $this->belongsToMany(Product::class);
    }

Product model belongsToMany orders

public function orders()
    {
        return $this->belongsToMany(Order::class);
    }

In the controller, when i $request-> the data and create a record in the orders table it works.
However when i added the attach method i getCall to a member function products() on null Please can someone tell me where i’m going wrong"-

Controller

$form_data = array(

'product_id' => $request->input('option_id'), // this is to accept the product_id checkboxes in an array.
'make'            => $request->make,
'mdl'             => $request->mdl,
'mdl_year'        => $request->mdl_year,
'engine'          => $request->engine,
'transmission'    => $request->transmission,
  );

        Order::create($form_data);

        $order = \App\Order::find('id');
        $order->products()->attach('product_id');
        
        return redirect.......

Please can someone tell me where i’m going wrong as i’ve tried many different ways and i’ve been stuck on this for nearly a week.

Thank you in advance.