assoconnect/absolute-percent-value-bundle
Symfony bundle that adds an AbsolutePercentValue field/type to handle percentage inputs safely, normalizing values and enabling comparisons, calculations, and validation without sign/format issues. Useful for forms and domain models needing absolute percentage values.
assoconnect/absolute-percent-value-bundle appears tailored for applications requiring dynamic value calculations (e.g., discounts, pricing tiers, or conditional logic where values are expressed as absolute or percentage-based rules). This aligns well with Laravel’s modular, business-logic-centric architecture, particularly in e-commerce, SaaS, or financial systems where hybrid value calculations (e.g., "10% off + $5 discount") are common.AbsolutePercentValue::calculate($base, $percent, $absolute)).$percent + $absolute doesn’t exceed a threshold).config/app.php.created, updated).percent_value, absolute_value, max_threshold). Schema migrations should align with Laravel’s migration system.percent_value > 100%)?NaN, negative values) handled?Product, Order).laravel/validation for input sanitization.redis or laravel-cache for performance optimization.monolog, guzzle).config/app.php.AbsolutePercentValue).class Product extends Model {
public function getDiscountedPriceAttribute() {
return $this->price - AbsolutePercentValue::calculate(
$this->price,
$this->discount_percent,
$this->discount_absolute
);
}
}
Rule::absolutePercent()).ProductUpdated) to recalculate values.Product::updated(function ($product) {
$product->refreshDiscountedPrice();
});
Cache::remember).percent_value, absolute_value).How can I help you explore Laravel packages today?