9951 explained code solutions for 126 technologies


php-laravelHow do I use Laravel Nova to develop a PHP application?


Laravel Nova is a powerful administration panel for Laravel applications. It provides a simple, fluent API for managing database resources. To use Laravel Nova to develop a PHP application, you need to:

  1. Install Laravel Nova: composer require laravel/nova
  2. Setup Nova: php artisan nova:install
  3. Create a Nova Resource:
php artisan make:nova Post
  1. Define fields for the resource:
public function fields(Request $request)
{
    return [
        ID::make()->sortable(),
        Text::make('Title')->sortable(),
        Textarea::make('Body')->rules('required'),
        BelongsTo::make('User')
    ];
}
  1. Create a Nova Resource Controller:
php artisan nova:resource PostController
  1. Register the resource in the NovaServiceProvider:
public function resources()
{
    Nova::resources([
        Post::class
    ]);
}
  1. Create a view for the resource:
php artisan nova:view Post

For more information, see the Laravel Nova documentation.

Edit this code on GitHub