Customer.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace yiiunit\extensions\mongodb\data\ar;
  3. use yiiunit\extensions\mongodb\data\ar\file\CustomerFile;
  4. /**
  5. * @property \MongoDB\BSON\ObjectID|string $_id
  6. * @property string $name
  7. * @property string $email
  8. * @property string $address
  9. * @property string $status
  10. * @property string $file_id
  11. */
  12. class Customer extends ActiveRecord
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static function collectionName()
  18. {
  19. return 'customer';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function attributes()
  25. {
  26. return [
  27. '_id',
  28. 'name',
  29. 'email',
  30. 'address',
  31. 'status',
  32. 'file_id',
  33. ];
  34. }
  35. /**
  36. * @return \yii\mongodb\ActiveQuery
  37. */
  38. public function getOrders()
  39. {
  40. return $this->hasMany(CustomerOrder::className(), ['customer_id' => '_id']);
  41. }
  42. /**
  43. * @return \yii\mongodb\ActiveQuery
  44. */
  45. public function getFile()
  46. {
  47. return $this->hasOne(CustomerFile::className(), ['_id' => 'file_id']);
  48. }
  49. /**
  50. * {@inheritdoc}
  51. * @return CustomerQuery
  52. */
  53. public static function find()
  54. {
  55. return new CustomerQuery(get_called_class());
  56. }
  57. }