|
|
|
@ -0,0 +1,36 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace App\Model\v3; |
|
|
|
|
|
|
|
use App\Model\Model; |
|
|
|
use Hyperf\Database\Model\Builder; |
|
|
|
use Hyperf\Database\Model\SoftDeletes; |
|
|
|
|
|
|
|
class StoreType extends Model |
|
|
|
{ |
|
|
|
use SoftDeletes; |
|
|
|
|
|
|
|
protected $table = 'lanzu_store_type'; |
|
|
|
|
|
|
|
protected function boot(): void |
|
|
|
{ |
|
|
|
parent::boot(); |
|
|
|
static::addGlobalScope('status', function (Builder $builder) { |
|
|
|
$builder->where(['status' => 1]); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public function goodsTypes() |
|
|
|
{ |
|
|
|
// firstKey是中间表联当前表的列,secondKey是远程表对应中间表的列,localKey是当前表关联中间表的列,secondLocalKey是中间表关联远程表的列
|
|
|
|
return $this->hasManyThrough( |
|
|
|
GoodsType::class, |
|
|
|
TypeCorrelation::class, |
|
|
|
'store_type_id', |
|
|
|
'id', |
|
|
|
'id', |
|
|
|
'goods_type_id' |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |