'boolean']; } public function organization(): BelongsTo { return $this->belongsTo(Organization::class, 'organization_id'); } public function branch(): BelongsTo { return $this->belongsTo(Branch::class, 'branch_id'); } public function batches(): HasMany { return $this->hasMany(DrugBatch::class, 'drug_id'); } public function stockOnHand(): int { return (int) $this->batches()->sum('quantity_on_hand'); } }