PHPackages                             emilianotisato/nova-belongsto-depends - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. emilianotisato/nova-belongsto-depends

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

emilianotisato/nova-belongsto-depends
=====================================

A Laravel Nova field with dependencie on another BelongsTo relationship.

0.1.4(7y ago)215.7k↓88%1[4 issues](https://github.com/emilianotisato/nova-belongsto-depend/issues)MITVuePHP &gt;=7.1.0

Since Aug 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/emilianotisato/nova-belongsto-depend)[ Packagist](https://packagist.org/packages/emilianotisato/nova-belongsto-depends)[ RSS](/packages/emilianotisato-nova-belongsto-depends/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (11)Used By (0)

BelongsTo Field with Dependency
===============================

[](#belongsto-field-with-dependency)

This package is based on the original [Orlyapps](https://github.com/orlyapps) package, which we do not know if is still under maintenance.

Installation
------------

[](#installation)

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require emilianotisato/nova-belongsto-depends
```

Use this field in your Nova Resource

```
// Add the use statement a the top of your nova resource
use EmilianoTisato\NovaBelongsToDepends\NovaBelongsToDepends;

// ...

public function fields(Request $request)
{
    return [
        ID::make()->sortable(),
        Text::make('Name')->rules('required', 'max:255'),

        NovaBelongsToDepends::make('Company')
            ->options(\App\Company::all()),
        NovaBelongsToDepends::make('Department')
            ->optionsResolve(function ($company) {
                // Reduce the amount of unnecessary data sent
                return $company->departments()->get(['id','name']);
            })
            ->dependsOn('Company'),
        NovaBelongsToDepends::make('Location')
            ->optionsResolve(function ($company) {
                // Reduce the amount of unnecessary data sent
                return $company->locations()->get(['id','name']);
            })
            ->dependsOn('Company'),

    ];
}
```

Sample
------

[](#sample)

- Warehouse hasMany Articles
- Articles belongsToMany Suppliers
- Suppliers belongsToMany Articles

1. Select a **Warehouse** and get all articles of the warehouse
2. Select a **Article** and get all suppliers who has this article

```
public function fields(Request $request)
{
    return [
        ID::make()->sortable(),
        Text::make('Name')->rules('required', 'max:255'),

        NovaBelongsToDepends::make('Warehouse')
        ->options(\App\Warehouse::all())
        ->rules('required'),
        NovaBelongsToDepends::make('Article')
            ->optionsResolve(function ($warehouse) {
                return $warehouse->articles;
            })
            ->dependsOn('Warehouse')
            ->rules('required'),
        NovaBelongsToDepends::make('Supplier')
            ->optionsResolve(function ($article) {
                return \App\Supplier::whereHas('articles', function ($q) use ($article) {
                    $q->where('article_id', $article->id);
                })->get();
            })
            ->dependsOn('Article')
            ->rules('required'),

    ];
}
```

Use multiple instances
----------------------

[](#use-multiple-instances)

Some times you need to use multiple instances o mabye you have a second resource for the same eloquent model (example: App\\Nova\\User and App\\Nova\\Provider both represent App\\User model). In those cases to avoid conflict you can delcare the specific Nova resources in meta attributes (`->withMeta(['calledFromClass' => 'App\Nova\Provider'])`) like this:

```
            NovaBelongsToDepends::make('Client')
                ->options(\App\Client::all()),

            NovaBelongsToDepends::make('Provider')
                ->withMeta(['calledFromClass' => 'App\Nova\Provider'])
                ->optionsResolve(function ($client) {
                    return $client->providers()->active()->get(['id', 'name']);
                })->dependsOn('Client')
                ->rules('required'),
```

Credits
-------

[](#credits)

- Creator: [Orlyapps](https://github.com/orlyapps)
- Mantainers: [Emiliano Tisato](https://github.com/emilianotisato)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~0 days

Total

8

Last Release

2697d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18596215?v=4)[Emiliano Tisato](/maintainers/emilianotisato)[@emilianotisato](https://github.com/emilianotisato)

---

Top Contributors

[![emilianotisato](https://avatars.githubusercontent.com/u/18596215?v=4)](https://github.com/emilianotisato "emilianotisato (6 commits)")[![CasperLaiTW](https://avatars.githubusercontent.com/u/5094008?v=4)](https://github.com/CasperLaiTW "CasperLaiTW (4 commits)")[![orlyapps](https://avatars.githubusercontent.com/u/5220826?v=4)](https://github.com/orlyapps "orlyapps (4 commits)")[![drsdre](https://avatars.githubusercontent.com/u/809827?v=4)](https://github.com/drsdre "drsdre (1 commits)")[![glennwilton](https://avatars.githubusercontent.com/u/6619768?v=4)](https://github.com/glennwilton "glennwilton (1 commits)")

---

Tags

laravelnovabelongsTo relationshipfields depend

### Embed Badge

![Health badge](/badges/emilianotisato-nova-belongsto-depends/health.svg)

```
[![Health](https://phpackages.com/badges/emilianotisato-nova-belongsto-depends/health.svg)](https://phpackages.com/packages/emilianotisato-nova-belongsto-depends)
```

###  Alternatives

[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3423.6M8](/packages/optimistdigital-nova-multiselect-field)[inspheric/nova-defaultable

Default values for Nova fields when creating resources and running resource actions.

51177.6k1](/packages/inspheric-nova-defaultable)[murdercode/nova4-tinymce-editor

Boost your Laravel Nova with the TinyMCE editor.

17178.1k1](/packages/murdercode-nova4-tinymce-editor)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11258.1k](/packages/datomatic-nova-detached-actions)[wemersonrv/input-mask

A Laravel Nova custom field text with masks on input

1197.8k](/packages/wemersonrv-input-mask)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
