I have 2 model: Product and SellingProduct. SellingProduct store selling information as sold date, sold price. A product record has many selling product records.
I want to fetch latest selling product record of a product. I use hasOne but don't work.
$this->hasOne('LastSellingProduct', [
'foreignKey' => 'product_id',
'order' => ['LastSellingProduct.created' => 'DESC'],
'limit' => 1,
'propertyName' => 'last_selling_product',
'className' => 'SellingProducts'
]);
Please help me!