'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; public function scopeLatestFirst($qurey) { return $qurey->orderByDesc('created_at')->orderByDesc('id'); } public function product(): BelongsTo { return $this->belongsTo(Product::class); } public function getChangeTypeLabelAttribute(): string { return $this->change_type === 'in' ? '입고' : '출고'; } public function getSignedAmountAttribute(): int { return $this->change_type === 'in' ? (int) $this->change_amount : -(int) $this->change_amount; } }