How to get related model data of related model

If I have declared relationships like in guide:




class Customer extends \yii\db\ActiveRecord

{

    public function getOrders()

    {

        // Customer has_many Order via Order.customer_id -> id

        return $this->hasMany(Order::className(), ['customer_id' => 'id']);

    }

}


class Order extends \yii\db\ActiveRecord

{

    public function getCustomer()

    {

        // Order has_one Customer via Customer.id -> customer_id

        return $this->hasOne(Customer::className(), ['id' => 'customer_id']);

    }


    public function getProducts()

    {

        // Order has_many Product via Product.id -> product_id

        return $this->hasMany(Order::className(), ['id' => 'product_id']);

    }

}



Plus one more, relation of Product with Orders ( I am assuming that Product has one order, real relationship doesn’t really matter ) :


class Product extends \yii\db\ActiveRecord

{

    public function getOrders()

    {

        // Product has_one Order via Order.product_id -> id

        return $this->hasOne(Order::className(), ['product_id' => 'id']);

    }

}

Now I would like to get all orders and all products for the given customer:


$data = Customer::find()->with('order')->with('product')->where(['id' => $id])->all();

But this doesnt, work, I get error that product relation is not defined in Customer model. Am I doing something wrong, or this is not possible ? Thanks