| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Models;
- use App\Enums\StoreItemStatusEnum;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class StoreItem extends Model
- {
- use SoftDeletes;
- protected $guarded = ['id'];
- protected function casts(): array
- {
- return [
- 'price' => 'float',
- 'associate_price' => 'float',
- 'supplier_price' => 'float',
- 'size_s' => 'boolean',
- 'size_m' => 'boolean',
- 'size_l' => 'boolean',
- 'size_xl' => 'boolean',
- 'stock_s' => 'integer',
- 'stock_m' => 'integer',
- 'stock_l' => 'integer',
- 'stock_xl' => 'integer',
- 'status' => StoreItemStatusEnum::class,
- ];
- }
- public function category(): BelongsTo
- {
- return $this->belongsTo(Category::class);
- }
- public function interests(): HasMany
- {
- return $this->hasMany(StoreItemInterest::class);
- }
- public function media(): HasMany
- {
- return $this->hasMany(Media::class, 'source_id')->where('source', 'store_item');
- }
- }
|