- How do I install oobook/priceable in a Laravel application?
- Install oobook/priceable with Composer using composer require oobook/priceable, then add the Priceable trait to any Eloquent model that needs pricing. The package follows Laravel-native configuration, so you can publish and adjust its config if needed. After that, define or configure the price attributes and start attaching prices through the polymorphic relationship.
- How do I attach prices to an Eloquent model with oobook/priceable?
- Add the Priceable trait to your model, then use the package's polymorphic price relationship to create or associate price records. This lets products, services, or any other Eloquent entity share the same pricing mechanism. You can retrieve prices through the relationship or the formatting helpers provided by the package.
- Does oobook/priceable support multiple currencies and formatted price output?
- Yes. oobook/priceable stores monetary values precisely and provides currency-aware formatting helpers so you do not scatter currency logic across your app. You can configure price attributes and accessors to return clean, formatted amounts. The package is designed to work alongside existing migrations and casts.
- Which Laravel versions does oobook/priceable support?
- The package is built on Laravel's Eloquent and configuration systems, but the exact Laravel version constraint is defined in its composer.json. Check that constraint before installing, especially on older or pre-release Laravel versions. For current supported Laravel releases, installation is a normal Composer require plus trait setup.
- How are monetary values stored and cast by oobook/priceable?
- oobook/priceable keeps monetary values precise in storage while exposing clean amounts through configurable accessors. It is compatible with existing migrations and casts, so you can keep your current price columns if they fit the package's configuration. The Priceable trait and polymorphic relationship handle the model-level pricing behavior.
- Can I use oobook/priceable with existing price columns or migrations?
- Yes. The package is described as compatible with existing migrations and casts, and its price attributes are configurable. You can map oobook/priceable to existing price columns rather than rewriting your schema. Review the configuration options to align attribute names and accessors with your current database structure.
- How do I configure price attributes and accessors in oobook/priceable?
- Configuration is Laravel-native, typically through a package config file where you define price attributes and accessors. You can customize which attributes are treated as prices and how formatted values are returned. Add the Priceable trait to your model and adjust the config to match your currency and storage conventions.
- Is oobook/priceable suitable for production Laravel applications?
- oobook/priceable is suitable for production Laravel applications that need trait-based pricing and polymorphic price relationships, provided you test it against your schema and currency requirements. Because pricing is business-critical, verify precise storage, formatting output, and relationship behavior in your test suite. Also confirm the package's maintenance status and Laravel version compatibility before deploying.
- How do I test pricing behavior with oobook/priceable in Laravel?
- Test oobook/priceable like any other Eloquent behavior: create models with the Priceable trait, attach prices through the polymorphic relationship, and assert both stored values and formatted accessor output. Use Laravel's database assertions to confirm precise monetary storage. Include currency formatting cases so regressions in accessors are caught.
- What are alternatives to oobook/priceable for pricing Laravel models?
- Alternatives include writing custom Eloquent casts and accessors for price columns, using money value-object libraries such as moneyphp/money or brick/money, or adopting dedicated currency formatting packages. oobook/priceable stands out by combining a Priceable trait with polymorphic price relationships for attaching prices to any model. Choose based on whether you need shared polymorphic pricing or simpler per-column money handling.