123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Models\Goods;
- use App\Base\BaseModel;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Support\Arr;
- class Goods extends BaseModel
- {
- use SoftDeletes;
- protected $table = "goods";
- const STATUS_OK = 1;
- const STATUS_OFF = 2;
- protected $casts = [
- "image_list" => "array",
- "spec" => "array",
- ];
- public function format(...$options)
- {
- }
- public function map()
- {
- return $this->hasMany(GoodsCategoryMap::class, "goods_id", "id");
- }
- public function sku()
- {
- return $this->hasMany(GoodsSku::class, "goods_id", "id");
- }
- public function getThumbAttribute()
- {
- return Arr::first($this->image_list);
- }
- public function specMap()
- {
- return $this->hasMany(GoodsSpecMap::class, "goods_id", "id");
- }
- }
|