123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App\Models;
- use App\Base\BaseModel;
- use App\Models\Goods\Goods;
- use Illuminate\Support\Arr;
- /**
- * App\Models\Cart
- *
- * @property int $id
- * @property int $user_id
- * @property int $goods_id
- * @property array $extra
- * @property int $count
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @method static \Illuminate\Database\Eloquent\Builder|Cart newModelQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|Cart newQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|Cart query()
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereCount($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereCreatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereExtra($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereGoodsId($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereId($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereUpdatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder|Cart whereUserId($value)
- * @mixin \Eloquent
- * @property-read mixed $thumb
- * @property-read mixed $goods_name
- * @property-read mixed $sn
- * @property-read mixed $custom
- * @property-read mixed $sku_id
- * @property-read Goods|null $goods
- */
- class Cart extends BaseModel
- {
- protected $table = "cart";
- protected $casts = [
- "extra" => "array",
- ];
- public function getThumbAttribute()
- {
- return Arr::get($this->extra, "thumb", "");
- }
- public function getSnAttribute()
- {
- return Arr::get($this->extra, "sn", "");
- }
- public function getSkuIdAttribute()
- {
- return Arr::get($this->extra, "sku_id", "");
- }
- public function getGoodsNameAttribute()
- {
- return Arr::get($this->extra, "goods_name", "");
- }
- public function getCustomAttribute()
- {
- return Arr::get($this->extra, "custom", []);
- }
- public function goods()
- {
- return $this->belongsTo(Goods::class);
- }
- }
|