123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace App\Models\Goods;
- use App\Base\BaseModel;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Support\Arr;
- /**
- * App\Models\Goods\Goods
- *
- * @property int $id
- * @property string $name
- * @property array $image_list
- * @property array $spec 商品的规格
- * @property int $weight
- * @property string|null $desc_html
- * @property string|null $spec_attr_html
- * @property string|null $faq_html
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @method static \Illuminate\Database\Eloquent\Builder|Goods newModelQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|Goods newQuery()
- * @method static \Illuminate\Database\Query\Builder|Goods onlyTrashed()
- * @method static \Illuminate\Database\Eloquent\Builder|Goods query()
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereCreatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereDeletedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereDescHtml($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereFaqHtml($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereId($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereImageList($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereName($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereSpec($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereSpecAttrHtml($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereUpdatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereWeight($value)
- * @method static \Illuminate\Database\Query\Builder|Goods withTrashed()
- * @method static \Illuminate\Database\Query\Builder|Goods withoutTrashed()
- * @mixin \Eloquent
- * @property int $status 1 上架 2下架
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereStatus($value)
- * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Goods\GoodsCategoryMap[] $map
- * @property-read int|null $map_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Goods\GoodsSku[] $sku
- * @property-read int|null $sku_count
- * @property-read mixed $thumb
- * @property int $view_total
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereViewTotal($value)
- * @property string $sn
- * @property string $url_3d
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereSn($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereUrl3d($value)
- * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Goods\GoodsSpecMap[] $specMap
- * @property-read int|null $spec_map_count
- * @property array $custom
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereCustom($value)
- * @property string $en_name
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereEnName($value)
- * @property string|null $en_desc_html
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereEnDescHtml($value)
- * @property string|null $en_spec_attr_html
- * @property string|null $en_faq_html
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereEnFaqHtml($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Goods whereEnSpecAttrHtml($value)
- */
- class Goods extends BaseModel
- {
- use SoftDeletes;
- protected $table = "goods";
- const STATUS_OK = 1;
- const STATUS_OFF = 2;
- protected $casts = [
- "image_list" => "array",
- "spec" => "array",
- "custom" => "array",
- ];
- public function format(...$options)
- {
- }
- public function map()
- {
- return $this->hasMany(GoodsCategoryMap::class, "goods_id", "id");
- }
- public function getThumbAttribute()
- {
- return Arr::first($this->image_list);
- }
- public function specMap()
- {
- return $this->hasMany(GoodsSpecMap::class, "goods_id", "id");
- }
- }
|