PHPackages                             keko94/nova-inline-relationship-extended - 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. [Templating &amp; Views](/categories/templating)
4. /
5. keko94/nova-inline-relationship-extended

ActiveLibrary[Templating &amp; Views](/categories/templating)

keko94/nova-inline-relationship-extended
========================================

A Laravel Nova field for displaying relationship properties inline.

1.0.8(2y ago)035MITPHPPHP ^7.4|^8.0

Since Mar 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Keko-94/nova-inline-relationship-extended)[ Packagist](https://packagist.org/packages/keko94/nova-inline-relationship-extended)[ RSS](/packages/keko94-nova-inline-relationship-extended/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (4)Versions (9)Used By (0)

⚠️ Experimental Project / Support &amp; Future Development
----------------------------------------------------------

[](#warning-experimental-project--support--future-development)

Please note that this is experimental and is not actively maintained and supported by our team. If you are interested in helping to maintain/extend this project please reach out.

Background: we initially started this project in 2019 to add inline relationship functionality to Laravel Nova. In addition to running into some significant complexities that prevented us from efficiently moving forward, Laravel Nova has since added functionality that covers most, but not all, of what we were trying to accomplish here. We recommend using those core Laravel Nova features instead of this package at this point.

[![Banner](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/resources/imgs/banner.png "Banner")](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/resources/imgs/banner.png)

Nova Inline Relationship
------------------------

[](#nova-inline-relationship)

[![Latest Version on Packagist](https://camo.githubusercontent.com/99d43da458ac7c501ac7574a85c3296c17fba6b603cf1c5f261fee5cd9a6eed3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69727363686261756d2d646576656c6f706d656e742f6e6f76612d696e6c696e652d72656c6174696f6e736869702e737667)](https://packagist.org/packages/kirschbaum-development/nova-inline-relationship)[![Total Downloads](https://camo.githubusercontent.com/84d0505f97ea2b42187a8d4a727245322b14385f1e2b2fb3e615189763af1d24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b69727363686261756d2d646576656c6f706d656e742f6e6f76612d696e6c696e652d72656c6174696f6e736869702e737667)](https://packagist.org/packages/kirschbaum-development/nova-inline-relationship)[![Codacy Badge](https://camo.githubusercontent.com/7d133dc44df5f703f35d1c2f5adfeb625b5f85090f77e7feb33f175673478187/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3536323937653662373736303466333761353035656466323334636132613462)](https://www.codacy.com/manual/Kirschbaum/nova-inline-relationship?utm_source=github.com&utm_medium=referral&utm_content=kirschbaum-development/nova-inline-relationship&utm_campaign=Badge_Grade)[![Actions Status](https://github.com/kirschbaum-development/nova-inline-relationship/workflows/CI/badge.svg)](https://github.com/kirschbaum-development/nova-inline-relationship/actions)

Nova Inline Relationship allows you to manage (add/edit/update/delete/reorder) an object's relationships directly from the parent object's create/edit screens. By presenting relationships as inline properties you can provide content editors with a streamlined and efficient workflow for managing complex data.

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

[](#requirements)

This Nova field requires Nova 2.0 or higher.

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

[](#installation)

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

```
composer require kirschbaum-development/nova-inline-relationship
```

Usage
-----

[](#usage)

To use `NovaInlineRelationshipExtended` in your Model's resource all you need to do is to add an inline method to the regular syntax of your related Model's Resource field(s).

If we assume that a `BlogPost` model has a one-to-many relationship with `Image`, your `BlogPost` resource would look like the following:

```
namespace App\Nova;

use Laravel\Nova\Fields\Image;

class BlogPost extends Resource
{
    //...
    public function fields(Request $request)
    {
        return [
            //...

            HasMany::make('Images', 'images', Image::class)->inline(),
        ];
    }
}
```

***NOTE:*** You will need to add a Nova Resource for `Image` - all of the fields and rules will be retrieved from the specified resource. You must specify the resource as the third argument to the Relationship field as illustrated above.

Adding related models
---------------------

[](#adding-related-models)

[![Create View](screenshots/CreateView.png "Create View")](screenshots/CreateView.png)

After setup you can add new related models directly while creating a new base model. You can use the `Add new Image` button to add a new `Image` to the `BlogPost`:

[![Create Related Model](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/CreateViewExpanded.png "Create Related Model")](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/CreateViewExpanded.png)

Viewing related models
----------------------

[](#viewing-related-models)

Related models will also now be displayed inline as well:

[![Detail View](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/DetailView.png "Detail View")](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/DetailView.png)

Updating related models
-----------------------

[](#updating-related-models)

You can also update, re-arrange (for one-to-many relationships), and delete related models:

[![Rearrange Models](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/UpdateView.png "Rearrange Models")](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/UpdateView.png)

You can add drag and drop functionality for related models to update their order by using the `sortUsing()` method. In the following code example we use a field named `order` to store the sort order for the `Images` model:

```
HasMany::make('Images')->inline()->sortUsing('order'),
```

Required Relationships
----------------------

[](#required-relationships)

Occasionally you may want to require a child relationship during the creation of a model. To do this, just use the `requireChild()` method. As an example, you may want to create a new user and enforce that a new profile for the user is also created.

```
HasOne::make('Profile', 'profile', Profile::class)->inline()->requireChild(),
```

Support for Third Party Packages
--------------------------------

[](#support-for-third-party-packages)

We have included a simple way to address some issues regarding third party packages occasionally not working with Nova Inline Relationships. These packages occasionally handle how they return their subset of fields slightly different. We have a way of easily integrating functionality for these packages. This may not work across the board, but should allow for most third party packages.

You must publish the configs for this package with

```
php artisan vendor:publish
```

This will publish a config file as `config/nova-inline-relationships.php`. Add your custom namespaced paths within the `third-party` array. For example:

```
'third-party' => [
    'App\Nova\ThirdPartyIntegrations',
    'Keko94\NovaInlineRelationshipExtended\Integrations',
]
```

Create a new class inside that namespace that looks like the following:

```
