*/ protected function casts(): array { return [ 'quantity' => 'integer', ]; } /** * @return BelongsTo */ public function product(): BelongsTo { return $this->belongsTo(Product::class); } /** * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * @return MorphTo */ public function reference(): MorphTo { return $this->morphTo(); } public function isIn(): bool { return $this->direction === 'in'; } /** * Vorzeichenbehaftete Menge (Eingang positiv, Ausgang negativ). */ public function signedQuantity(): int { return $this->isIn() ? (int) $this->quantity : -(int) $this->quantity; } }