Customer.php 833 Bytes
Newer Older
1 2
<?php

3
namespace yiiunit\data\ar\mongodb;
4

5 6
use yiiunit\data\ar\mongodb\file\CustomerFile;

7 8
class Customer extends ActiveRecord
{
9 10 11 12
    public static function collectionName()
    {
        return 'customer';
    }
13

14 15 16 17 18 19 20 21
    public function attributes()
    {
        return [
            '_id',
            'name',
            'email',
            'address',
            'status',
22
            'file_id',
23 24
        ];
    }
25

26 27 28 29
    public function getOrders()
    {
        return $this->hasMany(CustomerOrder::className(), ['customer_id' => '_id']);
    }
30

31 32 33 34 35
    public function getFile()
    {
        return $this->hasOne(CustomerFile::className(), ['_id' => 'file_id']);
    }

Alexander Makarov committed
36 37 38 39 40
    /**
     * @inheritdoc
     * @return CustomerQuery
     */
    public static function find()
41
    {
42
        return new CustomerQuery(get_called_class());
43
    }
AlexGx committed
44
}