1. Go to this page and download the library: Download yassi/nova-nested-form library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yassi / nova-nested-form example snippets
namespace App\Nova;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Gravatar;
use Laravel\Nova\Fields\Password;
// Add use statement here.
use Yassi\NestedForm\NestedForm;
class User extends Resource
{
...
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make(),
Text::make('Name')
->sortable()
->rules('m::make('Posts'),
];
}
class Post extends Resource
{
...
public function fields(Request $request)
{
return [
Boolean::make('Has Comments'),
NestedForm::make('Comments')->displayIf(function ($nestedForm, $request) {
return [
[ 'attribute' => 'has_comments', 'is' => true ]
];
];
}
})