nhrrob/crudgenerator

This package provides an artisan command to generate a basic crud

v2.3.1 2024-09-18 04:31 UTC

README

Stars Total Downloads Latest Stable Version GitHub license

This package provides an artisan command to generate a basic crud

composer install command:

composer require nhrrob/crudgenerator

Crud Generator Commands

  • install:
php artisan crud:generator
  • If you want to keep backend files under Admin folder
    File Structure: Check below (Section => Bonus : Admin File Structure)
php artisan crud:generator --admin
  • Migration: Add title field and run migration
    • add field:
    $table->string('title');
    
    • run migration:
    php artisan migrate
    

Note:

  • This package creates resource route. Example:
    • Model title: Post
    • Resource route: example.com/posts
  • If you want to use Api, make sure Sanctum (or, Passport) is installed.
    Link: https://github.com/nhrrob/laravelwiki

Loom Videos:

Modify Stubs:

  • Publish vendor files
php artisan vendor:publish

Remove Crud Generated Files:

  • Delete Crud
php artisan crud:generator:delete
  • If you have generated crud under Admin folder:
php artisan crud:generator:delete --admin
  • Manually delete migration file and remove route from web.php

Feel free to contact:
nazmulrobin.com | Twitter | Linkedin | Email

Bonus

Laravel 8 auth using laravel/ui:

composer require laravel/ui
php artisan ui bootstrap --auth
npm install && npm run dev
php artisan migrate

Bonus : API

API Helpline:

php artisan passport:install

Bonus : Admin File Structure

  • When you add --admin in crud generator commands =>
    It adds admin folder for views and Admin folder for controllers (including Api)

  • Sample File/Folder Structure:

#Controllers
app/Http/Controllers/
app/Http/Controllers/Admin

#Views
resources/views/
resources/views/admin

------------------------------

#API Controllers
app/Http/Controllers/Api
app/Http/Controllers/Api/Admin

V2.3.0

  • Config file added
  • Api versioning support added
  • Api versions will be managed in dedicated version folder (e.x. app/Http/Controllers/Api/V1 and app/Http/Controllers/Api/V1/Admin)
  • Now delete command will also delete migration file. You dont need to manually remove it.
  • API AuthController will be added under versioning folder. (Probably - https://github.com/nhrrob/laravel-11-api-crud/tree/master/app/Http/Controllers/Api/V1/Admin has no auth under versioning. But I am adding auth under versioning for get started project. Also crud generator creates under versioning folder).