PHP code example of handleglobal / nova-nested-form
1. Go to this page and download the library: Download handleglobal/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/ */
handleglobal / 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 Handleglobal\NestedForm\NestedForm;
class User extends Resource
{
...
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make(),
Text::make('Name')
->sortable()
->rules('('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 ]
];
];
}
})