- How do I install escolalms/cart in a Laravel application?
- Install it with Composer by running composer require escolalms/cart. Laravel package discovery should register the service provider automatically; if not, add it to your providers configuration. Then run the package migrations and verify the cart routes are available. Check the repository README and composer.json for any version constraints before installing.
- Which Laravel versions does escolalms/cart support?
- The package is built for Laravel applications in the EscolaLMS ecosystem, but the exact Laravel version constraints are defined in its composer.json. Check that file and the package releases before installing, because the project is on a 0.x version line and constraints can change between releases. Test the install in a development environment that matches your production PHP and Laravel versions.
- Does escolalms/cart include database migrations and models?
- Yes. The package provides shopping-cart models and migrations so you can persist carts and cart items in your database. Run php artisan migrate after installation to create the required tables. Review the migration files first if you need to customize table names or integrate with an existing schema.
- What REST API endpoints does escolalms/cart provide?
- The package exposes REST API endpoints for adding products to a cart, updating item quantities, removing items, and calculating cart totals. Routes follow standard Laravel and EscolaLMS conventions, so you can inspect them with php artisan route:list. Authentication and authorization are typically handled by the surrounding EscolaLMS user and API layers.
- How do I add a product to the cart through the API?
- Send a request to the cart add-product endpoint with the product identifier and quantity, using an authenticated EscolaLMS user token. Confirm the exact route, payload field names, and response shape with php artisan route:list or the package API documentation. After adding, call the cart or totals endpoint to verify the line item and computed total.
- How does escolalms/cart calculate cart totals?
- The package includes an endpoint that calculates cart totals from the products and quantities currently stored in the cart. Totals are based on the product data available to the package, so make sure your product model exposes the price fields the cart expects. Add tests for edge cases such as zero quantities, removed items, and unavailable products.
- Is escolalms/cart production-ready despite being on a 0.x version?
- The package is usable in production, but 0.x versioning means minor releases can include behavior changes, so pin a tested Composer constraint. Run regression tests for cart operations and API response contracts before upgrading. Roll out changes through development and staging, and monitor the cart endpoints after deployment.
- How do I upgrade escolalms/cart to version 0.4.81?
- Bump the Composer constraint to 0.4.81, run composer update escolalms/cart, and clear Laravel caches. Verify that service provider discovery is intact and that the product/me endpoint now returns the categories array. No schema migration is indicated for this release, but check the changelog and run migrations in a safe environment to confirm.
- Will the new categories array in product/me cause N+1 queries or break API clients?
- The categories field is an additive response change, but it can introduce N+1 queries if the category relation is not eager-loaded. Monitor query counts on the product/me endpoint and eager-load categories where appropriate. Clients that enforce strict response schemas may reject the extra field, so coordinate with frontend and API consumers before deploying.
- How should I test escolalms/cart in my Laravel application?
- Write feature tests that authenticate an EscolaLMS user and exercise adding, updating, removing, and totaling cart items. Assert the JSON response shapes, including the categories array in product/me, and check query counts for N+1 issues. Run the suite in CI against the same Laravel and PHP versions you use in production.