1. Go to this page and download the library: Download lupennat/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/ */
lupennat / 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 Lupennat\NestedForm\NestedForm;
class User extends Resource
{
...
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make(),
Text::make('Name')
->sortable()
->rules('make('Posts'),
];
}
use Lupennat\Nova\Resource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Lupennat\NestedForm\HasNestedForm;
class Posts extends Resource
{
use HasNestedForm;
public function fields(Request $request)
{
return array_filter([
ID::make(),
BelongsTo::make(__('User'), 'user', User::class),
Select::section(__('Section'), 'section')->options(['sport' => 'Sport', 'news' => 'News'])->rules('