Commit 04b6baa8 by Alexander Makarov

Added hints for defining AR relations to docs

parent ab5d7bd5
......@@ -202,12 +202,14 @@ 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
{
// Order has_one Customer via Customer.id -> customer_id
public function getCustomer()
{
return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment