lupennat / many-inline
Laravel Nova - Many Inline Table
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:Vue
pkg:composer/lupennat/many-inline
Requires
- php: ^7.4|^8.0
- laravel/nova: ^4.12
- nova-kit/nova-packages-tool: ^1.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
README
Requirements
php: ^7.4 | ^8laravel/nova: ^4
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require lupennat/many-inline
Usage
ManyInline Packages automatically enable a new method inline for all Many Relationship Fields:
- HasMany
- BelongsToMany
- HasManyThrough
- MorphToMany
The table will be displayed as a Field of the resource, without any actions and without the toolbar.
use Laravel\Nova\Fields\HasMany; use Laravel\Nova\Http\Requests\NovaRequest; class User extends Resource { public function fields(Request $request) { return [ HasMany::make('User Post', 'posts', Post::class)->inline(); ]; } }
You can manage Field visibility on related resource through the new methods hideWhenInline or onlyOnInline.\
to manage field visibility you must include the
HasManyInlinetrait on related resource.
use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\BelongsTo; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; use Lupennat\ManyInline\HasManyInline; class Posts extends Resource { use HasManyInline; public function fields(Request $request) { return [ ID::make(), BelongsTo::make(__('User'), 'user', User::class)->hideWhenInline(), Text::make(__('Extra Field'), 'extra')->onlyOnInline() ]; } }