Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Coupons For Laravel Laravel Package

roundly-consulting/coupons-for-laravel

Coupons for Laravel makes it easy to add discount coupons to your application. Create and manage codes, define flexible redemption rules, validate coupons at checkout, track usage, and integrate promotions cleanly with your Eloquent models and Laravel workflows.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install the package with Composer, then publish any config/provider assets if the package exposes them (php artisan vendor:publish). Start by reading the package config file and service provider to understand how models are configured and swapped.
  • Identify the model resolution entry point: look for config keys, container bindings, or a resolver class that maps a logical model to a concrete Eloquent class.
  • First use case: create a record through the package factory and confirm which model class is instantiated. Then swap the configured model in a test or service provider and verify the factory follows the swap. Release 1.1.2 specifically fixes factories building the configured model when a host swaps it, so validate that behavior first if you rely on model substitution.

Implementation Patterns

  • Use the package factories as the default way to create test and seed data. Prefer Factory::new()->create() / ->make() over direct new Model calls so configured model resolution is honored.
  • When a host application needs a custom model, swap it through the package’s supported mechanism — typically a config value, container binding, or provider registration — rather than overriding factory classes directly.
  • In tests, swap models at the container level (e.g. $this->app->bind(...) or the package’s swap helper) and assert the factory returns an instance of the swapped class. This is the workflow 1.1.2 targets.
  • Extend base factories with states and sequences for common scenarios, but keep the model class resolution delegated to the package so swaps continue to work.
  • For integration, resolve models through the container or package resolver in your own services; avoid hard-coding concrete model class names in factories, seeders, or test helpers.
  • Use the package’s model resolver as an extension point: decorate or rebind it in a service provider when you need conditional model selection (e.g. per-tenant models).

Gotchas and Tips

  • Upgrade to 1.1.2 if you swap configured models in hosts. Earlier versions could build the original model instead of the swapped one, causing confusing test failures or wrong-table writes.
  • Clear cached config after changing model bindings (php artisan config:clear). Stale config is a common reason a swap appears not to take effect.
  • Ensure swapped models implement the same contract/interface and table expectations as the default. The factory will now build the configured class, but it will not adapt schema differences for you.
  • Debug model resolution by dumping the class returned from the package resolver or factory (get_class($factory->make())). If it is not the swapped class, check binding order, provider registration, and config cache.
  • Avoid hard-coded model references inside custom factories; use the package’s resolver or resolve() so future swaps and the 1.1.2 fix remain effective.
  • Extension points to review: publishable config for default model mappings, the model resolver/binding in the service provider, and factory base classes. Prefer these over forking package internals.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib