- What does khaled-dev/nova-belongs-to-dependency do?
- It extends Laravel Nova's BelongsTo field so the selectable options can depend on another field's value. When the parent field changes, the dependent BelongsTo options are filtered dynamically and refreshed automatically. It is designed for Nova resources where relationships need cascading or conditional selection.
- How do I install khaled-dev/nova-belongs-to-dependency?
- Install it with Composer using composer require khaled-dev/nova-belongs-to-dependency. Then use the package's field class in your Nova resource in place of the standard BelongsTo field. Check the repository README for the exact namespace, class name, and any required setup steps.
- Which parent field types can control the dependent BelongsTo field?
- The package overview lists BelongsTo, Text, and Status fields as supported dependencies. That covers common cases like filtering a city by country, a subcategory by category, or options by a status value. Confirm the exact supported types in the README for your Nova version.
- Does the BelongsTo select refresh automatically when the parent field changes?
- Yes, the package is built to refresh the dependent BelongsTo options automatically when the parent selection changes. This avoids stale options after a user updates the controlling field. The dynamic filtering is a core feature described in the package overview.
- Is this package compatible with Laravel Nova 4 or Nova 5?
- Compatibility depends on the package release, so check the composer.json and README in the GitHub repository for the supported Nova and Laravel versions. Nova major versions can introduce breaking field API changes. Confirm the version constraints before adding it to a production project.
- How do I configure which field the BelongsTo depends on?
- You configure the dependency in your Nova resource when defining the field, typically by naming the parent field and the dependent relationship. The exact method names and syntax are package-specific, so follow the README examples. The goal is to tell the field which value should drive its option filtering.
- Can I filter BelongsTo options using a Text or Status field value?
- Yes, the package supports BelongsTo, Text, and Status fields as dependencies according to its overview. That means you can drive option filtering from a typed value or a status selection, not only from another relationship. Review the README for any per-type configuration details.
- How should I test a dependent BelongsTo field in Laravel Nova?
- Test both the server-side option query and the Nova field behavior, since the package filters options dynamically and refreshes on parent changes. Use Laravel's testing tools and Nova's field testing helpers where applicable. Also check the repository's own tests for examples of expected configuration and behavior.
- Are there production performance concerns with dynamic BelongsTo filtering?
- Dynamic filtering can add queries when Nova loads or refreshes options, so keep option queries constrained and indexed for large datasets. Test with realistic data volumes and confirm your Nova resource authorization and relationship scoping still apply. Review the package README for any recommended caching or query customization.
- What are alternatives to nova-belongs-to-dependency?
- You can build custom Nova BelongsTo option callbacks and front-end dependency logic yourself, but that takes more maintenance. Other Nova field packages or dependency-focused packages may also cover cascading selects. This package is focused specifically on making BelongsTo options depend on BelongsTo, Text, or Status fields.