Skip to content

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

License

Notifications You must be signed in to change notification settings

alitnk/nova-parental-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages