PHPackages                             reedware/nova-field-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. reedware/nova-field-manager

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

reedware/nova-field-manager
===========================

Creates a field facade for referencing fields.

v1.0.2(4y ago)03.9k↓14.3%MITPHPPHP &gt;=7.1.0

Since May 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/tylernathanreed/nova-field-manager)[ Packagist](https://packagist.org/packages/reedware/nova-field-manager)[ RSS](/packages/reedware-nova-field-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Nova Field Manager
------------------

[](#nova-field-manager)

This package provides the convenience of not having to include the class path of each individual field in your resource class declaration. A new `Field` facade will be created, where you can defer all field creation through.

[![Latest Stable Version](https://camo.githubusercontent.com/1628565a0e2afc91b3d432f1a56db63d33a2fe8646c63ed6c1087bc1aaf161dc/68747470733a2f2f706f7365722e707567782e6f72672f72656564776172652f6e6f76612d6669656c642d6d616e616765722f762f737461626c65)](https://packagist.org/packages/reedware/nova-field-manager)[![Total Downloads](https://camo.githubusercontent.com/42c7e041bb08ded887ab17fdbdd4d31ca4977047cd794fb83010cf997d7b2117/68747470733a2f2f706f7365722e707567782e6f72672f72656564776172652f6e6f76612d6669656c642d6d616e616765722f646f776e6c6f616473)](https://packagist.org/packages/reedware/nova-field-manager)[![License](https://camo.githubusercontent.com/26e9840130d483b5b6903194cd1c3a83a665008062a8080f9c2565a881115e4e/68747470733a2f2f706f7365722e707567782e6f72672f72656564776172652f6e6f76612d6669656c642d6d616e616765722f6c6963656e7365)](https://packagist.org/packages/reedware/nova-field-manager)

Installation
------------

[](#installation)

Require this package with composer.

```
composer require reedware/nova-field-manager
```

Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the service provider or facade. However, should you still need to reference them, here are their class paths:

```
\Reedware\NovaFieldManager\NovaFieldManagerServiceProvider::class // Service Provider
\Reedware\NovaFieldManager\Facade::class // Facade
```

Usage
-----

[](#usage)

You can now add fields to your resources in Nova by using the `Field` facade, rather than having to include each individual field in your resource class definition.

```
/**
 * Get the fields displayed by the resource.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return array
 */
public function fields(Request $request)
{
    return [
        Field::id()->sortable(),

        Field::text('Name', 'display_name')
            ->sortable()
            ->rules('required', 'max:100'),

        Field::textarea('Description')
            ->rules('max:255'),

        Field::hasMany('Tasks', 'tasks', Task::class),

        Field::number('Tasks', function() {
            return $this->tasks_count;
        })

    ];
}
```

Custom Fields
-------------

[](#custom-fields)

All of the fields are configured in the `nova-fields` configuration file. First, you will need to create your own copy, by either running the `php artisan vendor:publish` command, or by copying the configuration file directory from this repository (found in `~/config/nova-fields.php`).

You can easily add your own (or override the default fields) by manipulating this configuration file. The config key (`id`, `text`, `hasMany`, etc) is the method that you can call from the `Field` facade. The config value is the class path to the field, where a call to `Field::(...)` defers to `::make(...)`.

The default fields provided by Nova will automatically be added, even if they are not present in your configuration file. However, if you have overridden one of the default fields (by specifying the same key name), your field will override the default Nova field.

```
