PHPackages                             aqjw/nova-belongs-to-dependency - 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. aqjw/nova-belongs-to-dependency

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

aqjw/nova-belongs-to-dependency
===============================

Extended Laravel Nova BelongsTo field that can depend on other fields

v4.0.8(3y ago)0271—0%MITVuePHP ^8.0.2

Since Jun 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/aqjw/nova-belongs-to-dependency)[ Packagist](https://packagist.org/packages/aqjw/nova-belongs-to-dependency)[ RSS](/packages/aqjw-nova-belongs-to-dependency/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (11)Used By (0)

Nova BelongsTo dependency
=========================

[](#nova-belongsto-dependency)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8a301184c3bb53d000d973b7057b2fdba78c71dfad023c02033be3b2785a2686/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61716a772f6e6f76612d62656c6f6e67732d746f2d646570656e64656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aqjw/nova-belongs-to-dependency)[![Total Downloads](https://camo.githubusercontent.com/8ec48b40ce383c6127b66d3f1aa3d719cb8a017d682acb773d8f77358f4aaf50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61716a772f6e6f76612d62656c6f6e67732d746f2d646570656e64656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aqjw/nova-belongs-to-dependency)

This package is an extension of Laravel Nova's existing BelongsTo field and Vue components.

Requirements
------------

[](#requirements)

- PHP 8.0.2+
- Nova 4+

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Methods](#methods)
        - [dependsOn](#dependson)
        - [searchable](#searchable)
        - [buildQuery](#buildquery)
        - [formatResource](#formatresource)
- [License](#license)

### Installation

[](#installation)

This package can be installed via command:

```
composer require aqjw/nova-belongs-to-dependency
```

### Usage

[](#usage)

The following will list categories with `type_id` equal to the value set in the first BelongsTo field.

```
use Aqjw\BelongsToDependency\BelongsToDependency;
...
return [
    ...
    BelongsTo::make('Type'),

    BelongsToDependency::make('User')
        ->dependsOn('type', 'type_id')
    ...
];
```

### Methods

[](#methods)

#### dependsOn

[](#dependson)

The method can take one or two parameters. If you don't pass the second parameter, it will be generated from first one with the `_id` suffix.

This may depend on `BelognsTo`, `Text`, `Enum`, and others 🤷

```
BelongsToDependency::make('User')
    ->dependsOn('type', 'type_id'),
```

##### Multiple dependency

[](#multiple-dependency)

You can also pass an array as the first parameter. To make a dependency on two or more fields.

```
BelongsToDependency::make('User')
    ->dependsOn(['type', 'role']),
```

Or

```
BelongsToDependency::make('User')
    ->dependsOn([
        'type' => 'type_id',
        'role' => 'role_id',
    ]),
```

#### searchable

[](#searchable)

Use this method if you have many entries.

```
BelongsTo::make('Country')
    ->searchable(),

BelongsToDependency::make('State')
    ->searchable()
    ->dependsOn('country'),

BelongsToDependency::make('City')
    ->searchable()
    ->dependsOn('state'),
```

#### buildQuery

[](#buildquery)

If you want to add your own conditions to the query then greet the `buildQuery` method.

```
BelongsToDependency::make('Product')
    ->dependsOn('category')
    ->buildQuery(function ($query, $values) {
        $query->where($values)
            ->where('status', 'active');
    }),
```

#### formatResource

[](#formatresource)

Use this method to change the resource format. This can be useful if you want to group items.

```
BelongsToDependency::make('Product')
    ->dependsOn('category')
    ->formatResource(function ($resource) {
        return [
            'display' => $resource->name,
            'value' => $resource->id,
            'group' => $resource->parent_category,
        ];
    })
```

### License

[](#license)

The MIT License (MIT). Please see License File for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

10

Last Release

1412d ago

Major Versions

v1.0.0 → 4.0.02022-06-25

PHP version history (2 changes)v1.0.0PHP ^7.3|^8.0

4.0.0PHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bbc50eee573168342cf8eaa53bcc09048939b7dc4bb79187133c919ce6e1e8b?d=identicon)[aqjw](/maintainers/aqjw)

---

Top Contributors

[![aqjw](https://avatars.githubusercontent.com/u/13101908?v=4)](https://github.com/aqjw "aqjw (16 commits)")

---

Tags

laravelnovabelongs-to

### Embed Badge

![Health badge](/badges/aqjw-nova-belongs-to-dependency/health.svg)

```
[![Health](https://phpackages.com/badges/aqjw-nova-belongs-to-dependency/health.svg)](https://phpackages.com/packages/aqjw-nova-belongs-to-dependency)
```

###  Alternatives

[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2872.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2861.8M9](/packages/outl1ne-nova-sortable)[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3403.5M7](/packages/optimistdigital-nova-multiselect-field)[digital-creative/conditional-container

Provides an easy way to conditionally show and hide fields in your Nova resources.

116593.8k4](/packages/digital-creative-conditional-container)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

57215.9k](/packages/sbine-route-viewer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

14720.0k](/packages/markwalet-nova-modal-response)

PHPackages © 2026

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