- What does unisharp/buyable do in Laravel?
- unisharp/buyable is a Laravel package that adds buyable behavior to Eloquent models. It provides contracts and traits to standardize pricing and purchasing so your models can integrate with carts, checkout, and order workflows. It does not replace a full cart or order system; it gives your models a consistent buyable interface.
- How do I install unisharp/buyable with Composer?
- Install it with Composer using composer require unisharp/buyable. Laravel package discovery should register the service provider automatically in modern Laravel versions. Check the repository README for any publish, configuration, or migration commands that may be required for your setup.
- Which Laravel versions does unisharp/buyable support?
- The package repository and its composer.json are the authoritative source for supported Laravel and PHP versions. Check those constraints before installing, especially if your application runs an older or very new Laravel release. The provided overview does not list explicit version requirements, so verify compatibility against your app.
- How do I make an Eloquent model buyable?
- Add the package's buyable trait to your Eloquent model and implement the required buyable contract. This gives the model standardized methods for pricing and purchasing behavior. Follow the README or source for the exact trait name, interface, and method signatures your version expects.
- What contracts does unisharp/buyable provide?
- The package provides contracts that define buyable behavior for Eloquent models. These interfaces standardize how a model exposes pricing and purchasing information to carts, checkout, and order workflows. The traits supply default implementations so you do not have to write the same boilerplate in every buyable model.
- Can I use unisharp/buyable with a shopping cart or checkout package?
- Yes, the package is intended for use with carts, checkout, and order workflows. It standardizes the buyable model behavior so cart or checkout code can interact with different models consistently. Your actual cart, checkout, and order logic still lives in your application or another package.
- How does pricing work with unisharp/buyable?
- Pricing is standardized through the package's buyable contract and trait, so your models expose price information in a consistent way. The exact price fields, accessors, and configuration depend on the implementation in the repository. As with any commerce code, store monetary values in integer minor units and format them only for display to avoid floating-point issues.
- Is unisharp/buyable suitable for production?
- It is a lightweight integration package, so production suitability depends on its maintenance status, test coverage, and compatibility with your Laravel version. Review the repository's composer constraints, open issues, and recent activity before adopting it. Test it in staging with your actual cart and checkout flows, since the package provides contracts and traits rather than a complete commerce system.
- How do I test a buyable model in Laravel?
- Create a model instance that uses the buyable trait and implements the contract, then assert that its price and purchasing methods return the expected values. Use Laravel's testing helpers and database traits such as RefreshDatabase when your model needs persistence. Review the package tests for examples of expected behavior, and mock cart or order dependencies in your own tests.
- What are alternatives to unisharp/buyable?
- Alternatives include implementing your own buyable contract and trait, using a full ecommerce package such as Lunar or Aimeos, or choosing a cart package that already supports buyable models. unisharp/buyable is best when you only need lightweight standardization of pricing and purchasing behavior. Evaluate alternatives based on whether you need a full commerce stack or just a consistent model interface.