MallGoods.php 688 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\admin\model;
  3. use app\common\model\TimeModel;
  4. use think\model\relation\BelongsTo;
  5. use think\model\relation\HasOne;
  6. class MallGoods extends TimeModel
  7. {
  8. protected function getOptions(): array
  9. {
  10. return [
  11. 'deleteTime' => 'delete_time',
  12. ];
  13. }
  14. // * +++++++++++++++++++++++++++
  15. // | 以下两种写法适用于 with 关联
  16. // * +++++++++++++++++++++++++
  17. // public function cate(): BelongsTo
  18. // {
  19. // return $this->belongsTo('app\admin\model\MallCate', 'cate_id', 'id');
  20. // }
  21. public function cate(): HasOne
  22. {
  23. return $this->hasOne(MallCate::class, 'id', 'cate_id');
  24. }
  25. }