lupennat/many-inline

This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel Nova - Many Inline Table

v1.0.0 2023-05-22 14:03 UTC

This package is auto-updated.

Last update: 2023-12-12 11:35:59 UTC


README

  1. Requirements
  2. Installation
  3. Usage

Requirements

  • php: ^7.4 | ^8
  • laravel/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 HasManyInline trait 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()
        ];
    }
}