GitHunt
CE

cerpinn/nova-parental-field

A Laravel Nova field made for Parental to quickly make a select element to choose the child type

Nova Parental Field

A Laravel Nova field made for Parental to quickly make a select element to choose the child type

Installation

composer require alitnk/nova-parental-field

Usage

use Wama\NovaParentalField\Parental;

 public function fields(Request $request)
    {
        return [
            // ... your other fields
            
            Parental::make()->searchable(),
        ];
    }

The parental field extends Nova's select field. so you can make use of methods like searchable() on it.

Passing the field's name is optional, the package will automatically get the field name based on your $childColumn property and if there is none, it'll just default to type.

After making the field, it automatically gets the children types and populates them in the select field.


So, assuming your parent model looks like this:

class User extends Model {
    use HasChildren;

    private $childTypes = [
        'admin' => Admin::class,
        'moderator' => Moderator::class,
        'author' => Author::class,
    ];
}

After you add the Parental::make()->searchable() to your Nova fields, you should get the following result:

nova-parental-field-1

Languages

PHP100.0%

Contributors

Latest Release

v0.0.0July 8, 2021
MIT License
Created July 7, 2021
Updated September 3, 2023