treestoneit / belongs-to-field
A Laravel Nova Belongs To field that respects Eager Loading
Installs: 30 647
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2019-10-07 01:41:40 UTC
README
A Laravel Nova Belongs To field that respects Eager Loading
In current version of Laravel Nova Eager Loading is not working with Default BelongsTo Field
For a temporary workaround that does not break updatability:
We made a new field that extends the existing BelongsTo Class
Installation
Install the package into a Laravel app that uses Nova with Composer:
composer require treestoneit/belongs-to-field
To use
Change all uses of BelongsTo
to this BelongsToField
.
If a proper fix is available in the future, just change it back to the nova one.
So resulting code resource should look like this:
... use Treestoneit\BelongsToField\BelongsToField; ... ... public function fields(Request $request) { return [ ... BelongsToField::make('User') ... ]; } ... ...
Credits
Thanks to Michael Münch for this solution