jspaceboots / laracrud
Provides quick application scaffolding as well as HTML & JSON API interfaces for model CRUD.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
Language:CSS
Requires
- php: ~7.1
- doctrine/dbal: ~2.5
- illuminate/support: ~5.1
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2025-03-23 17:43:58 UTC
README
Provides quick application scaffolding as well as HTML and JSON API interfaces for model CRUD.
Project Goal
To give you the ability to scaffold your data model in thirty minutes or less by hand or by script.
We let you quickly produce everything necessary (models, transformers, repositories, etc.) and wire it together in a single console command, instantly exposing your data for Create Read Update and Delete operations via both an "Admin Panel" web GUI and a RESTful JSON API.
tl;dr: You write migrations, we give you an admin panel + API
Project Status
ALPHA
Super early days, feature incomplete, USE AT YOUR OWN RISK.
Install
Via Composer
$ composer require jspaceboots/laracrud
Quickstart
First you need to publish the config and public assets:
php artisan vendor:publish
Next modify your applications config/crud.php to suit the needs of your project. Once you're done:
php artisan laracrud:make:model MySingularModel
This will generate the files necessary for LaraCRUD to hook into your data model, specifically a:
- Model
- Repository
- Transformer
- Migration
These will be generated in directories matching the namespaces laid out in config/crud.php. For instance, if your repositories namespace is set to "\App\Repositories\" the generated repository will be written to app/repositories. The one exception is the migration, which will be placed in database/migrations. In addition to generating these files the generated model will be added to the routing configuration in config/crud.php.
From here you only need to fill out the generated migration and then run:
php artisan migrate
At this point all non-relational fields of your model should be fully accessible via http://{{domain}}/crud/{{model}} and http://{{domain}}/api/crud/{{model}}
LaraCRUD Conventions
Table conventions
- LaraCRUD requires the PK of every entity be 'id'.
- LaraCRUD requires FKs to conform to this syntax: {{foreign_model}}_id
- examples: toaster_id, user_role_id
- LaraCRUD requires the name of join tables for M:N relations to conform to this syntax: {{model_table_1}}_{{model_table_2}} (order is not important)
- examples: users_roles, toasters_heating_coils
- LaraCRUD requires that join tables for M:N relations will contain at least two columns: {{foreign_model_1}}_id & {{foreign_model_2}}_id
- examples: user_id & role_id, toaster_id & heating_coil_id
The laracrud:make:model command will generate table names by transforming your camel case model name (MyModel) into an underscore seperated representation and pluralizing the last word (my_models).
Model conventions
- LaraCRUD requires model names to be singular and camel cased
- examples: User, Toaster, HeatingCoil
- LaraCRUD requires you define an array of validator strings on your model (laracrud:make:model will stub this)
- LaraCRUD supports using UUIDs for model PKs with the installation of: https://github.com/webpatser/laravel-uuid
- with 'useUuids' enabled in config/crud.php laracrud:make:model will generate models that auto-populate V4 UUIDs as their PK
Relations
- LaraCRUD requires foreign keys conform to conventions laid out in Table conventions above
- LaraCRUD requires you to define some additional metadata in your Repositories in order to traverse/persist M:N relations and reverse 1:M
Filters
Removing the CRUD
If you're using LaraCRUD to bootstrap a project, or just wish to remove LaraCRUD at some future point, simply run:
php artisan laracrud:eject
This will remove the dependancy to LaraCRUDs Abstract classes from the models, repositories, and transformers that have been generated, remove the packages published configuration and assets from your project, and finally de-register the LaraCRUD service provider with your Laravel instance.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.