You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
687 B
31 lines
687 B
<?php
|
|
|
|
namespace App\Model\v3;
|
|
|
|
use App\Model\Model;
|
|
use Hyperf\Database\Model\Builder;
|
|
use Hyperf\Database\Model\SoftDeletes;
|
|
|
|
class Category extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'lanzu_category';
|
|
|
|
protected $appends = [
|
|
'goods_types'
|
|
];
|
|
|
|
protected function boot(): void
|
|
{
|
|
parent::boot();
|
|
static::addGlobalScope('status', function (Builder $builder) {
|
|
$builder->where(['status' => 1])->orderBy('sort', 'desc');
|
|
});
|
|
}
|
|
|
|
public function getGoodsTypesAttribute()
|
|
{
|
|
return self::query()->where(['parent_id' => $this->attributes['id']])->orderBy('sort', 'desc')->get()->toArray();
|
|
}
|
|
}
|