Smousss generates Laravel Nova resources in a few seconds using GPT-4 to help you speed up your admin panel's development.
namespace App\Nova;
use …
class Post extends Resource
{
public static $model = \App\Models\Post::class;
public static $title = 'title';
public static $search = [
'id', 'title', 'slug', 'content', 'description',
];
public function fields(Request $request)
{
return [
ID::make()->sortable(),
BelongsTo::make('User'),
Text::make('Title')
->rules('required', 'max:255'),
Slug::make('Slug')
->from('Title')
->rules('required', 'max:255')
->creationRules('unique:posts,slug')
->updateRules('unique:posts,slug,{{resourceId}}'),
Textarea::make('Content')
->rules('required'),
Textarea::make('Description')
->rules('required'),
HasMany::make('Comments'),
BelongsToMany::make('Tags'),
HasMany::make('Pins'),
];
}
}
Install the package via Composer:
composer require smousss/laravel-novalize
Publish the config file:
php artisan vendor:publish --tag=novalize-config
- First, generate a secret key on smousss.com.
- Add it to your
SMOUSSS_SECRET_KEY
environment variable. - Then, create a Nova resource based on your Post model:
php artisan smousss:novalize App\\Models\\Post
. Or for multiple models:php artisan smousss:novalize App\\Models\\Post App\\Models\\Comment
Novalize for Laravel has been developed by Benjamin Crozat for Smousss (Twitter).