Download .zip |
Info | Documentation | View files (105) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2019-11-12 (2 days ago) | Not yet rated by the users | Total: Not yet counted | Not yet ranked |
Version | License | PHP version | Categories | |||
laravel-crud 1.0 | GNU General Publi... | 7 | PHP 5, Libraries, Code Generation, De... |
Description | Author | |
This package can generate MVC classes for any Laravel model. |
|
Laravel Crud is a package for automatically adding CRUD (Create, Read, Update, Delete) views, web controllers and API controllers for any model as rapidly as possible.
Laravel Crud let's you quickly create all of the views and controllers you need for the full CRUD operation set (create, read, update, delete), including an index with just a configuration file. Laravel Crud also creates and registers routes for you automatically, giving you both web and API endpoints for your models with as little as one line in an array.
The intent of Laravel Crud is for rapid prototyping. All you need for your complete CRUD operation set is a model and corresponding database table. The properties and their types are read from the database and the appropriate UI controlls are rendered in the web UIs.
Install via composer.
composer require webbtj/crud
Once installed you'll want to publish a config file to edit.
php artisan vendor:publish
When prompted, select crud-config
. This will create config/crud.php
where
you can define the models you want crud functionality generated for.
You can list any models you want crud functionality for in the config/crud.php
configuration file. This file returns an array, each element in the array can be
either a string naming a model, or an array with additional configuration
options such as which fields are read only, excluded from certain views, and
even validation. When specifying the model name, you can include the full
namespace of the model (App\Employee
) or simply the name of the class itself
(Employee
). The model name is also case-insensitive.
Example configuration file:
return [
'models' => [
// Add your model class names here (full namespace)
// Exmaple: "App\\Employee"
"App\\SmallChild", // a string that will create all routing and views
// for the model with all defaults.
[
'model' => "App\\FastCar", // specify the model with extra configs
'index' => [
'exclude' => ['created_at'], // don't show this property in the
// index view
],
'store' => [
'validation' => [ // run this validation on the "store" method
'year' => 'required'
],
],
],
[
'model' => "App\\Employee",
'show' => [
'exclude' => ['sample_text', 'sample_string'],
],
'edit' => [
'exclude' => ['sample_longText'],
'readonly' => ['sample_char'], // in the edit interface, show
// this property but make it
// read only
],
'create' => [
'exclude' => ['sample_text'],
'include' => ['updated_at'], // include this property in the
// create interface (it's normally
// not included)
'readonly' => ['sample_integer'],
],
'index' => [
'include' => [
'id', 'first_name', 'last_name', 'email', 'sample_json',
'sample_jsonb', 'sample_enum', 'sample_set', 'enabled'
],
],
'update' => [
'validation' => [
'first_name' => 'required',
'last_name' => 'required',
],
]
]
]
];
You can specify include
, exclude
, and readonly
arrays of properties for
each of the four standard views, show
, edit
, create
, and index
. You can
also specify include
, exclude
, and validation
arrays for each of the two
standard methods, store
and update
. If you're specifying additional options
in an array format, you must include the model
definition as well.
While you have complete control over what fields are displayed and can be edited, there are defaults that the package will fall back to when you do not provide specifics. By default...
id
, created_at
, and updated_at
are not updateable via requestsIn all views except index
, you will exclude
fields you don't want displayed.
If you want to customize the index
view you will need to include
each
property.
But reading schemas for every interaction with a model, reading and parsing all of these inclusion, exclusion, read-only, and validation rules from a config, these are all pretty expensive operations and not really suited for production apps. That's why there's an artisan command to commit views and controllers to _your_ codebase for better performance and further development control.
php artisan crud:publish
The crud:publish
artisan command will create a directory for the model in your
views
directory with index
, show
, create
, and edit
views. It will also
create a web controller in your Http/Controllers
directory and an API
controller in your Http/Controllers/Api
directory. Finally it will provide
recommended code for adding the routes to your web.php
and api.php
routes
files, and recommend that you now remove the publish model(s) from your
crud.php
config file.
Of course you can customize and limit this publish with options. Provide
--model=
to speficfy the model you wish to publish. Omitting this option will
publish all models. This option allows for multiple values simply by specifying
it more than once
(Example: `php artisan crud:publish --model=Employee --model=Car).
You can also specify which elements you want published by specifying --type=
.
Like --model=
this can be repeated to specify multiple types to publish. The
valid types are as follows:
controller
- publishes the web controllerapi.controller
- publishes the API controllerviews
- publishes all viewsview.index
- publishes just the index viewview.show
- publishes just the show viewview.create
- publishes just the create viewview.edit
- publishes just the edit viewSome notes on these options. They are case insensitive; all punctuation is
stripped out (so api.controller
, api-controller
, and apicontroller
all
work); singular vs plural doesn't matter (English only); and the order of words
for the specific views doesn't matter (view.index
or index.view
).
Contributions are always welcome on GitHub. Please open issues before submitting PRs and do tag the issue in your commit messages/PR description. Also, please adhere to PSR-2 as much as possible.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (1 file, 7 directories) | ||||
composer.json | Data | Auxiliary data | ||
license | Lic. | License text | ||
readme.md | Doc. | Documentation |
Files | / | src |
Files | / | src | / | Http | / | Controllers |
File | Role | Description |
---|---|---|
CrudApiController.php | Class | Class source |
CrudBaseController.php | Class | Class source |
CrudWebController.php | Class | Class source |
Files | / | src | / | stubs |
File | Role | Description | ||
---|---|---|---|---|
views (5 files, 1 directory) | ||||
ApiController.php.stub | Class | Class source | ||
WebController.php.stub | Class | Class source |
Files | / | src | / | stubs | / | views |
File | Role | Description | ||
---|---|---|---|---|
partials (5 files, 1 directory) | ||||
create.blade.php.stub | Data | Auxiliary data | ||
edit.blade.php.stub | Data | Auxiliary data | ||
index.blade.php.stub | Data | Auxiliary data | ||
layout.blade.php.stub | Data | Auxiliary data | ||
show.blade.php.stub | Data | Auxiliary data |
Files | / | src | / | stubs | / | views | / | partials |
File | Role | Description | ||
---|---|---|---|---|
fields (4 directories) | ||||
create-column.blade.php.stub | Data | Auxiliary data | ||
edit-column.blade.php.stub | Data | Auxiliary data | ||
index-column.blade.php.stub | Data | Auxiliary data | ||
index-header.blade.php.stub | Data | Auxiliary data | ||
show-column.blade.php.stub | Data | Auxiliary data |
Files | / | src | / | stubs | / | views | / | partials | / | fields | / | create |
File | Role | Description |
---|---|---|
array-option.blade.php.stub | Data | Auxiliary data |
array.blade.php.stub | Data | Auxiliary data |
boolean.blade.php.stub | Data | Auxiliary data |
date.blade.php.stub | Data | Auxiliary data |
datetime.blade.php.stub | Data | Auxiliary data |
decimal.blade.php.stub | Data | Auxiliary data |
enum-option.blade.php.stub | Data | Auxiliary data |
enum.blade.php.stub | Data | Auxiliary data |
float.blade.php.stub | Data | Auxiliary data |
integer.blade.php.stub | Data | Auxiliary data |
json.blade.php.stub | Data | Auxiliary data |
string.blade.php.stub | Data | Auxiliary data |
text.blade.php.stub | Data | Auxiliary data |
time.blade.php.stub | Data | Auxiliary data |
_readonly.blade.php.stub | Data | Auxiliary data |
Files | / | src | / | stubs | / | views | / | partials | / | fields | / | edit |
File | Role | Description |
---|---|---|
array-option.blade.php.stub | Data | Auxiliary data |
array.blade.php.stub | Data | Auxiliary data |
boolean.blade.php.stub | Data | Auxiliary data |
date.blade.php.stub | Data | Auxiliary data |
datetime.blade.php.stub | Data | Auxiliary data |
decimal.blade.php.stub | Data | Auxiliary data |
enum-option.blade.php.stub | Data | Auxiliary data |
enum.blade.php.stub | Data | Auxiliary data |
float.blade.php.stub | Data | Auxiliary data |
integer.blade.php.stub | Data | Auxiliary data |
json.blade.php.stub | Data | Auxiliary data |
string.blade.php.stub | Data | Auxiliary data |
text.blade.php.stub | Data | Auxiliary data |
time.blade.php.stub | Data | Auxiliary data |
_readonly.blade.php.stub | Data | Auxiliary data |
Files | / | src | / | stubs | / | views | / | partials | / | fields | / | index |
File | Role | Description |
---|---|---|
array.blade.php.stub | Data | Auxiliary data |
boolean.blade.php.stub | Data | Auxiliary data |
json.blade.php.stub | Data | Auxiliary data |
_general.blade.php.stub | Data | Auxiliary data |
Files | / | src | / | stubs | / | views | / | partials | / | fields | / | show |
File | Role | Description |
---|---|---|
boolean.blade.php.stub | Data | Auxiliary data |
json.blade.php.stub | Data | Auxiliary data |
_general.blade.php.stub | Data | Auxiliary data |
Files | / | src | / | Traits |
File | Role | Description |
---|---|---|
CrudControllerTrait.php | Class | Class source |
PublisherTrait.php | Class | Class source |
Files | / | src | / | utilities |
File | Role | Description |
---|---|---|
EnumType.php | Class | Class source |
Field.php | Class | Class source |
helpers.php | Example | Example script |
Util.php | Class | Class source |
Files | / | src | / | views | / | crud |
File | Role | Description | ||
---|---|---|---|---|
fields (3 directories) | ||||
create.blade.php | Aux. | Auxiliary script | ||
edit.blade.php | Aux. | Auxiliary script | ||
index.blade.php | Aux. | Auxiliary script | ||
layout.blade.php | Aux. | Auxiliary script | ||
show.blade.php | Aux. | Auxiliary script |
Files | / | src | / | views | / | crud | / | fields | / | edit |
File | Role | Description |
---|---|---|
array.blade.php | Aux. | Auxiliary script |
boolean.blade.php | Aux. | Auxiliary script |
date.blade.php | Aux. | Auxiliary script |
datetime.blade.php | Aux. | Auxiliary script |
decimal.blade.php | Aux. | Auxiliary script |
enum.blade.php | Aux. | Auxiliary script |
float.blade.php | Aux. | Auxiliary script |
integer.blade.php | Aux. | Auxiliary script |
json.blade.php | Aux. | Auxiliary script |
string.blade.php | Aux. | Auxiliary script |
text.blade.php | Aux. | Auxiliary script |
time.blade.php | Aux. | Auxiliary script |
Files | / | src | / | views | / | crud | / | fields | / | index |
File | Role | Description |
---|---|---|
array.blade.php | Aux. | Auxiliary script |
boolean.blade.php | Aux. | Auxiliary script |
date.blade.php | Aux. | Auxiliary script |
datetime.blade.php | Aux. | Auxiliary script |
decimal.blade.php | Aux. | Auxiliary script |
enum.blade.php | Aux. | Auxiliary script |
float.blade.php | Aux. | Auxiliary script |
integer.blade.php | Aux. | Auxiliary script |
json.blade.php | Aux. | Auxiliary script |
string.blade.php | Aux. | Auxiliary script |
text.blade.php | Aux. | Auxiliary script |
time.blade.php | Aux. | Auxiliary script |
Files | / | src | / | views | / | crud | / | fields | / | show |
File | Role | Description |
---|---|---|
array.blade.php | Aux. | Auxiliary script |
boolean.blade.php | Aux. | Auxiliary script |
date.blade.php | Aux. | Auxiliary script |
datetime.blade.php | Aux. | Auxiliary script |
decimal.blade.php | Aux. | Auxiliary script |
enum.blade.php | Aux. | Auxiliary script |
float.blade.php | Aux. | Auxiliary script |
integer.blade.php | Aux. | Auxiliary script |
json.blade.php | Aux. | Auxiliary script |
string.blade.php | Aux. | Auxiliary script |
text.blade.php | Aux. | Auxiliary script |
time.blade.php | Aux. | Auxiliary script |
Version Control | Unique User Downloads | |||||||
100% |
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.