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

Forms For Laravel Laravel Package

roundly-consulting/forms-for-laravel

Forms for Laravel lets you define forms in code with a fluent API, render them in Blade, and handle validation and submissions cleanly. A lightweight way to build and manage dynamic forms without extra admin tooling.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install the package with Composer and run any published migrations/providers as documented. Since this is a patch release (1.0.4), there are no new setup steps required beyond a normal composer update.
  • Look first at the package config file (typically published to config/) for a model map or class overrides. The release note confirms the package supports “host swaps” of models — i.e. a host application can replace a package model with its own subclass or implementation.
  • First use case: in a host app, override one of the package’s models in config, then use the package factory in a test or seeder. On 1.0.4+, the factory should instantiate your configured model. Verify with:
    $model = Package\Factories\SomeModelFactory::new()->create();
    $this->assertInstanceOf(HostApp\Models\SomeModel::class, $model);
    
  • If you were previously on an older patch, this is the first thing to re-test after upgrading: factories that silently built the original package model will now correctly build the swapped host model.

Implementation Patterns

  • Config-driven model swapping. Host applications should override the package model via config rather than editing vendor code. The package resolves the configured class at runtime; factories now respect that resolution. Keep the config key documented in your host app’s deployment notes.
  • Factory usage in tests and seeders. Use the package factories as normal (Factory::new()->create(), ->count(5), states, etc.). After 1.0.4, the resulting model class follows the host’s swap. This makes it safe to write assertions against host model classes and relationships.
  • Custom factories. If you maintain your own factory for a swappable model, mirror the package’s resolution behaviour by overriding newModel() to return the configured class, e.g.:
    public function newModel(array $attributes = [])
    {
        $model = config('package.models.some_model', ParentModel::class);
        return new $model($attributes);
    }
    
    Otherwise your custom factory can still hardcode the original model and reintroduce the bug this release fixes.
  • Relationship and morph consistency. When swapping a model, update any polymorphic morph maps and relationship methods that reference the original class. Factories will create the swapped class, but relations defined with hardcoded class names may still point at the package model.
  • Integration tip: bind swapped models in a service provider if the package resolves models through the container. Prefer a single source of truth (config or container binding) so factories, queries, and relationship resolution all agree.

Gotchas and Tips

  • Clear cached config after swapping. Laravel caches config in production. Run php artisan config:clear (or redeploy with a fresh cache) after changing a model mapping, otherwise factories and runtime resolution can disagree.
  • Factory model guessing. If you rely on Laravel’s Factory::guessFactoryNamesUsing() or convention-based factory resolution, ensure the host model’s factory name still resolves. A swapped model may not have a matching factory class; use Factory::useNamespace() or explicit ->factory() calls.
  • States referencing class names. Factory states, afterMaking/afterCreating callbacks, and relationship definitions that reference the original model class by name will not automatically follow the swap. Audit them when overriding models.
  • Debugging: inspect what the factory builds with get_class(SomeFactory::new()->make()) or dd(SomeFactory::new()->newModel()). If you see the package model instead of the host model on 1.0.4+, check config caching and whether a custom factory overrides newModel().
  • Upgrade note: 1.0.4 is a patch-level bug fix for factory model resolution. It is low-risk, but tests that asserted the old (incorrect) class will need updating. No deprecations or breaking changes are indicated.
  • Extension points: publish the package factories if you need to customise model resolution; extend the package’s base factory rather than copying it so future fixes (like this one) propagate.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource