*/ use HasFactory, SoftDeletes; public const TYPE_FULL = 'full'; public const TYPE_PARTIAL = 'partial'; public const STATUS_RECEIVED = 'received'; public const STATUS_PROCESSING = 'processing'; public const STATUS_DONE = 'done'; public const STATUS_REJECTED = 'rejected'; protected $fillable = [ 'shopping_order_id', 'user_shop_id', 'type', 'status', 'order_reference', 'customer_email', 'customer_name', 'reason', 'items', 'ip_address', 'user_agent', 'admin_note', 'declared_at', ]; /** * @return array */ protected function casts(): array { return [ 'items' => 'array', 'declared_at' => 'datetime', ]; } public function shopping_order(): BelongsTo { return $this->belongsTo(ShoppingOrder::class, 'shopping_order_id'); } public function user_shop(): BelongsTo { return $this->belongsTo(UserShop::class, 'user_shop_id'); } public function scopeReceived(Builder $query): Builder { return $query->where('status', self::STATUS_RECEIVED); } /** * @return array */ public static function statuses(): array { return [ self::STATUS_RECEIVED, self::STATUS_PROCESSING, self::STATUS_DONE, self::STATUS_REJECTED, ]; } public function isFullWithdrawal(): bool { return $this->type === self::TYPE_FULL; } }