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.
|
|
<?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', 'cover_url' ];
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(); } public function getCoverUrlAttribute() { $url = $this->attributes['cover_img'];
if(strripos($url,"http") === false){ return config('alioss.img_host').'/'.$url; }else{ return $url; } }}
|