A Laravel package that generates complete CRUD modules with optional media library, translatable fields, relationships, and API resources.
- ✅ Complete CRUD Generation: Models, Migrations, Controllers, Requests, Views, Routes
- ✅ API Support: Generate API controllers and resources instead of web interfaces
- ✅ Media Library: Integration with Spatie Media Library for file uploads
- ✅ Translatable Fields: Support for Spatie Translatable package
- ✅ Relationships: Automatic relationship generation
- ✅ Form Validation: Automatic request validation classes
- ✅ Bootstrap Views: Ready-to-use Bootstrap-styled views
- ✅ Customizable: Publishable stubs and configuration
Install the package via Composer:
composer require nabila/crud-generatorThe package will automatically register its service provider.
For additional features, install these packages:
# For media library support
composer require spatie/laravel-medialibrary
# For translatable models
composer require spatie/laravel-translatableGenerate a complete CRUD module:
php artisan crud:make Post --fields="title:string,content:text,published:boolean"This generates:
app/Models/Post.phpdatabase/migrations/create_posts_table.phpapp/Http/Controllers/PostController.phpapp/Http/Requests/Post/StorePostRequest.phpapp/Http/Requests/Post/UpdatePostRequest.phpresources/views/posts/(index, create, edit, show)- Route definitions in
routes/web_generated.php
php artisan crud:make Product --fields="name:string,description:text,image:file,price:integer" --with-mediaphp artisan crud:make Article --fields="title:string,content:text,slug:string" --translatablephp artisan crud:make Post --fields="title:string,content:text" --relationships="belongsTo:User,hasMany:Comment"php artisan crud:make Product --fields="name:string,price:integer" --apiThis generates API controllers and resources instead of web views.
php artisan crud:make BlogPost --fields="title:string,slug:string,content:text,excerpt:text:nullable,featured_image:file,published:boolean,published_at:date:nullable" --with-media --translatable --relationships="belongsTo:User,belongsTo:Category,hasMany:Comment" --forcestring- VARCHAR fieldtext- TEXT fieldinteger- INTEGER fieldboolean- BOOLEAN fielddate- DATE fieldemail- VARCHAR with email validationfile- File upload field (works with --with-media)
Add :nullable to make fields optional:
--fields="name:string,description:text:nullable,age:integer:nullable"| Option | Description |
|---|---|
--fields |
Required. Comma-separated fields with types |
--with-media |
Include Spatie Media Library support |
--translatable |
Make model translatable |
--relationships |
Add relationships (belongsTo:Model,hasMany:Model) |
--api |
Generate API routes and controller |
--force |
Overwrite existing files |
php artisan crud:listapp/
├── Models/Post.php
└── Http/
├── Controllers/PostController.php
└── Requests/Post/
├── StorePostRequest.php
└── UpdatePostRequest.php
database/migrations/
└── 2024_01_01_000000_create_posts_table.php
resources/views/posts/
├── index.blade.php
├── create.blade.php
├── edit.blade.php
└── show.blade.php
routes/
└── web_generated.php
app/
├── Models/Post.php
└── Http/
├── Controllers/Api/PostController.php
├── Resources/PostResource.php
└── Requests/Post/
├── StorePostRequest.php
└── UpdatePostRequest.php
routes/
└── api_generated.php
Publish the configuration file:
php artisan vendor:publish --tag=nabila-crud-configPublish the stubs for customization:
php artisan vendor:publish --tag=nabila-crud-stubsAfter publishing stubs, you can customize the templates in stubs/nabila-crud/. The generator will use your custom stubs if they exist.
model.stub- Model templatemigration.stub- Migration templatecontroller.stub- Web controller templateapi-controller.stub- API controller templatestore-request.stub- Store request validationupdate-request.stub- Update request validationresource.stub- API resource templateviews/index.blade.stub- Index view templateviews/create.blade.stub- Create view templateviews/edit.blade.stub- Edit view templateviews/show.blade.stub- Show view templateroutes.stub- Web routes templateapi-routes.stub- API routes template
Add to your routes/web.php:
if (file_exists(__DIR__ . '/web_generated.php')) {
require __DIR__ . '/web_generated.php';
}Add to your routes/api.php:
if (file_exists(__DIR__ . '/api_generated.php')) {
require __DIR__ . '/api_generated.php';
}After generating your CRUD:
php artisan migrate- PHP 8.1+
- Laravel 10.0+, 11.x or 12.x
This package is open-sourced software licensed under the MIT license.
Please see CONTRIBUTING.md for details.
Please see CHANGELOG.md for more information on what has changed recently.
If you discover any security related issues, please email nabilashabban2000@gmail.com instead of using the issue tracker.