PHPackages                             miljoen/nova-autofill - 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. miljoen/nova-autofill

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

miljoen/nova-autofill
=====================

A Laravel Nova field.

v1.4(5y ago)43.4k[2 issues](https://github.com/Miljoen/nova-autofill/issues)MITVuePHP &gt;=7.1.0

Since Apr 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Miljoen/nova-autofill)[ Packagist](https://packagist.org/packages/miljoen/nova-autofill)[ RSS](/packages/miljoen-nova-autofill/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (6)Used By (0)

nova-autofill
=============

[](#nova-autofill)

nova-autofill is a Laravel Nova package that allows for automatic filling of Nova FormFields.

[![](https://camo.githubusercontent.com/73746bb09529493deb494e94caf39ea08bb7d398f4caae5cc836b30f7ae4e8bd/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f4b785764654c694f633559586d77374b6c552f67697068792e676966)](https://camo.githubusercontent.com/73746bb09529493deb494e94caf39ea08bb7d398f4caae5cc836b30f7ae4e8bd/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f4b785764654c694f633559586d77374b6c552f67697068792e676966)

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

[](#installation)

```
composer require Miljoen/nova-autofill

```

Example usage for fresh Laravel project.
----------------------------------------

[](#example-usage-for-fresh-laravel-project)

1. [Create a new Laravel project](https://laravel.com/docs/7.x/installation)
2. [Install Nova](https://nova.laravel.com/docs/)
3. Install the package using

    `composer require Miljoen/nova-autofill`
4. Add `use AutofillTrait;` to the `/app/User.php` Model.
5. Implement the `filterKey()` and `autofillModels()` methods.

    For example:

    ```
    function filterKey(): string
    {
        return 'email';
    }

    function autofillModels(): \Illuminate\Support\Collection
    {
        return collect([
            new \App\User(['name' => 'cedric', 'email' => 'cedric@cedric.cedric', 'password' => \Illuminate\Support\Facades\Hash::make('cedric')]),
            new \App\User(['name' => 'yoeri', 'email' => 'yoeri@yoeri.yoeri', 'password' => \Illuminate\Support\Facades\Hash::make('yoeri')])
        ]);
    }

    ```
6. Add `Autofill::make('Nova Autofill', 'id')->options( \App\User::filterKey(), \App\User::autofillModels()),`

    to the return value of the `fields()` function in `/app/Nova/User.php`
7. Go to the `.../nova/resources/users/new` route in your browser to test the package

The `/app/User.php` model should look like this:

```
