The relationship between MallGoods and MallCate has been updated to reflect a HasOne association rather than a BelongsTo. This change is reflected in the cate() method of the MallGoods model, enhancing the flexibility of the model relationships.
30 lines
634 B
PHP
30 lines
634 B
PHP
<?php
|
|
|
|
namespace app\admin\model;
|
|
|
|
use app\common\model\TimeModel;
|
|
use think\model\relation\BelongsTo;
|
|
use think\model\relation\HasOne;
|
|
|
|
class MallGoods extends TimeModel
|
|
{
|
|
|
|
protected $table = "";
|
|
|
|
protected $deleteTime = 'delete_time';
|
|
|
|
// * +++++++++++++++++++++++++++
|
|
// | 以下两种写法适用于 with 关联
|
|
// * +++++++++++++++++++++++++
|
|
|
|
// public function cate(): BelongsTo
|
|
// {
|
|
// return $this->belongsTo('app\admin\model\MallCate', 'cate_id', 'id');
|
|
// }
|
|
|
|
public function cate(): HasOne
|
|
{
|
|
return $this->hasOne(MallCate::class, 'id', 'cate_id');
|
|
}
|
|
|
|
} |