Skip to content

jdferreira/auto-crud

Repository files navigation

Laravel Auto CRUD Generator

This generator reads your database schema files and generates CRUD-related files based on that. See below form more details.

About this package

This package is highly inspired by the nafiesl/SimpleCrudGenerator package, which also provides a crud generator. However, that package creates simple stubs where all models are regarded as a set of two columns (name and description). Given this, it is still laborious to go back to each generated file (model, factory, tests, etc.) and change everything.

The package appzcoder/crud-generator is more complete, in the sense that it produces migrations based on a schema. However, it misses factories and tests.

The main contribution of this package, therefore, is a artisan command that generates crud-related files. The idea that distinguishes this package from those other ones is that the command fetches the details of a given table to generate the following:

  • a model
  • a controller
  • a form request for validation
  • a factory
  • a database seeder
  • views to the regular CRUD actions
  • a test file
  • resource routes

If an of these files already exists, they are not overwritten.

Usage

The command php artisan autocrud:generate Customer reads the information on table customers and generates the following files:

  • app/Customer.php: the eloquent model
  • app/Http/Controllers/CustomerController.php: the controller that converts requests into CRUD actions
  • app/Http/Requests/Customer.php: the form request file that validates user input
  • database/factories/CustomerFactory.php: the model factory file
  • resources/views/customer/{index,show,create,edit,_form}.blade.php: the _form view contains the form that is used both for the create and the edit actions.
  • tests/Feature/ManageCustomersTest.php: feature test class to test the high-level CRUD features

It also updates:

  • routes/web.php to add customers resource route
  • database/seeds/DatabaseSeeder.php to call the generated seeders

How to install

$ composer require jdferreira/autocrud --dev

About

Auto CRUD generator for Laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages