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.
This Nova field requires Nova 2.0 or higher.
You can install this package in a Laravel app that uses Nova via composer:
composer require kirschbaum-development/nova-inline-relationship
To use NovaInlineRelationship
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.
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
:
Related models will also now be displayed inline as well:
You can also update, re-arrange (for one-to-many relationships), and delete related models:
The following eloquent relationships are currently supported:
- BelongsTo
- HasOne
- HasMany
- MorphOne
- MorphMany
The following native Nova 2.0 fields are confirmed to work.
- Boolean
- Code
- Country
- Currency
- Date
- DateTime
- Markdown
- Number
- Password
- Place
- Select
- Text
- Textarea
- Timezone
- Trix
- Avatar
- Image
- File
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email navneet@kirschbaumdevelopment.com or nathan@kirschbaumdevelopment.com instead of using the issue tracker.
Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more about us or join us!
The MIT License (MIT). Please see License File for more information.