CRUD generator for Laravel 5.x with minimum setup required
CRUD generator for Laravel 5.x - Screenshots - Features - Installation - Usage - Customizing NVD CRUD Generator - Known Problems and Their Solutions, (*1)
, (*2)
composer require nvd/crud-generator
from the project directoryRegister the Service Provider in config/app.php
:, (*3)
'providers' => [ ... ... Nvd\Crud\Providers\NvdCrudServiceProvider::class, ],
Publish configuration file and view templates:, (*4)
php artisan vendor:publish
from the project directoryRun php artisan nvd:crud table_name
, (*5)
Now you can access http://your-site.com/table-name to access the CRUD app. (Here table-name
refers to the singular, slugged version of the table name. e.g., (*6)
NVD CRUD generator publishes a configuration file config/crud.php
. You can modify the default settings of the package here. The file is completely documented and hence self explanatory., (*7)
In case you don't like the default code that is generated for you, the templates for the generated model, controller and the views are located in the /resources/views/vendor/crud
directory. You are free to edit them as you like. Or make a copy of any of the templates directory and refer to it in the config/crud.php
., (*8)
vendor.crud.common.app
template as the layout. If you are using a different layout, specify it in the config/crud.php
The default view templates use classes from Bootstrap and Font Awesome. You can edit the templates and not use them or you can simply include them in your layout like the one below:, (*9)
<!DOCTYPE html> <html> <head> <title>Laravel Sandbox</title> <link rel="stylesheet" href="path/to/bootstrap.min.css"> <link rel="stylesheet" href="path/to/font-awesome.min.css"> </head> <body> <div class="container"> <div class="content"> @yield("content") </div> </div> </body> </html>
For Laravel 5.2, the generator generates routes inside the closure of the route group that applies the 'web' middleware group in the /app/Http/route.php
out of the box, as follows:, (*10)
Route::group(['middleware' => ['web']], function () { Route::resource('user-profile','UserProfileController'); // });
If, for some reasons, the routes are generated outside the closure, you should move them inside to avoid any exception while creating, editing or deleting a resource., (*11)
You can also tell the generator explicitly where to declare the routes by adding a comment: 'nvd-crud routes go here' and the generator will place the route declaration just after the comment., (*12)
Route::group(['middleware' => ['web']], function () { // nvd-crud routes go here });
config/app.php
. Declare the alias and the exception will be gone:'aliases' => [ // 'Input' => Illuminate\Support\Facades\Input::class, // ],
Note: Use of Input facade was removed in the latest version. So this error is expected not to appear anyway., (*13)
created_at
, updated_at
), please refer to Laravel docs about conventions.