arrahmouni/crud-generator

Generate crud for laravel modules

Installs: 95

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/arrahmouni/crud-generator

2.0.0 2026-02-02 00:11 UTC

This package is auto-updated.

Last update: 2026-02-02 11:10:04 UTC


README

Laravel CRUD Generator License

A powerful CLI tool to generate complete CRUD operations with translations, permissions, and modular architecture support.

📦 Features

  • One-Command CRUD Generation
  • API or Web CRUD – Choose between API-only (admin panel API) or web CRUD (with optional views)
  • Multilingual Support (Model translations + migration translations)
  • Modular Architecture (Works with nwidart/laravel-modules)
  • Optional Components:
    • Soft Delete & Disabled Status
    • Admin CRUD Controller (web or API)
    • Front (user) API Controller
    • Permissions System
    • Factories & Seeders
    • Form Requests
    • Blade Views (web CRUD only)
  • API Controller Structure – Controllers under Api/Admin (admin) and Api/Front (user-facing)
  • Custom Stub Support
  • Automatic Route Generation (web.php or api.php)
  • Permission Seeding

🚀 Installation

  1. Install via Composer:
composer require arrahmouni/crud-generator
  1. Publish configuration and stubs:
php artisan vendor:publish --provider="CrudGeneratorServiceProvider" --tag=config
php artisan vendor:publish --provider="CrudGeneratorServiceProvider" --tag=stubs

🛠 Configuration

Edit config/crud.php to customize:

return [
    'stub_path' => resource_path('stubs/'), // Custom stub path
    // Add other configuration parameters
];

🎯 Basic Usage

Generate a full CRUD structure with interactive prompts:

php artisan create:crud ModelName ModuleName

Example - Create a Product CRUD in Catalog module:

php artisan create:crud Product Catalog

🔧 Command Workflow

First question: Do you want to create an API or a web CRUD?

  • API CRUD – Admin panel API only (no views). Routes go to api.php. Admin API controller uses BaseApiCrudController (permissions, soft delete, disabled, bulk actions).
  • Web CRUD – Admin panel with optional Blade views. Routes go to web.php. Optional front (user) API controller in Api/Front.

Then you'll be asked:

  • Soft Delete
  • Disabled Status
  • Translations
  • Migrations
  • Factories
  • Seeders
  • Requests
  • Admin CRUD controller (web controller in Admin/ or API controller in Api/Admin/ depending on API vs web)
  • Front API controller (user-facing API in Api/Front/)
  • Paginate API controller(s)
  • Permissions
  • Views (web CRUD only; not asked for API CRUD)

📂 Generated Structure

Web CRUD (when web is chosen):

ModuleName/
├── Entities/
│   └── ModelName.php
├── Http/
│   ├── Controllers/Admin/
│   │   └── ModelNameController.php
│   ├── Controllers/Api/
│   │   ├── Admin/          (optional, when admin API crud)
│   │   │   └── ModelNameController.php
│   │   └── Front/          (optional, front API controller)
│   │       └── ModelNameController.php
│   ├── Services/
│   └── Requests/
├── Resources/
│   ├── ModelNameResource.php
│   └── views/...           (optional)
├── Database/
│   ├── migrations/
│   ├── factories/
│   └── seeders/
└── Routes/
    ├── web.php             (admin web routes)
    └── api.php             (admin API and/or front API routes)

API CRUD (when API is chosen): same as above but no views; admin CRUD controller is generated in Api/Admin/ (extends BaseApiCrudController). The service does not include the getDataTable method (used only for web admin).

🔄 Post-Creation Steps

If permissions were created:

  1. Add the translation key to the seeder file in the ability_group section
  2. Add the model icon in the Permission module config
  3. Add any additional permissions in the Permission module config

Web CRUD:

  • Add translation keys in admin::dashboard (aside_menu: {model}_management)
  • Add translation keys in admin::cruds
  • Add translation keys in admin::datatables

API CRUD:

  • Register admin API routes in the module api.php if needed (middleware, prefix)

Sync permissions:

php artisan module:seed Permission

Run migrations:

php artisan module:migrate ModuleName

🛡 Service Provider

The CrudGeneratorServiceProvider handles:

  • Command registration
  • Stub path configuration
  • Package asset publishing
  • Configuration management

📜 License

This package is open-source software licensed under the MIT license.

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Happy CRUD Generation! 🚀