├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── composer.json
├── config
└── crudgenerator.php
├── doc
├── README.md
├── configuration.md
├── fields.md
├── installation.md
├── options.md
├── templates.md
└── usage.md
├── phpunit.xml.dist
├── publish
└── views
│ └── admin
│ ├── dashboard.blade.php
│ └── sidebar.blade.php
├── src
├── Commands
│ ├── CrudApiCommand.php
│ ├── CrudApiControllerCommand.php
│ ├── CrudCommand.php
│ ├── CrudControllerCommand.php
│ ├── CrudLangCommand.php
│ ├── CrudMigrationCommand.php
│ ├── CrudModelCommand.php
│ └── CrudViewCommand.php
├── CrudGeneratorServiceProvider.php
└── stubs
│ ├── api-controller.stub
│ ├── controller.stub
│ ├── lang.stub
│ ├── migration.stub
│ ├── model.stub
│ └── views
│ └── blade
│ ├── create.blade.stub
│ ├── edit.blade.stub
│ ├── form-fields
│ ├── checkbox-field.blade.stub
│ ├── form-field.blade.stub
│ ├── input-field.blade.stub
│ ├── password-field.blade.stub
│ ├── radio-field.blade.stub
│ ├── select-field.blade.stub
│ ├── textarea-field.blade.stub
│ └── wrap-field.blade.stub
│ ├── form.blade.stub
│ ├── index.blade.stub
│ └── show.blade.stub
└── tests
├── CrudGeneratorTest.php
├── Kernel.php
├── TestCase.php
└── temp
└── .gitignore
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 | composer.lock
3 | .DS_Store
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 8.0
5 | - 8.2
6 |
7 | sudo: false
8 |
9 | install: travis_retry composer install --no-interaction --prefer-dist --no-suggest
10 |
11 | script: vendor/bin/phpunit --verbose
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2015-2017 Sohel Amin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel CRUD Generator
2 |
3 | [](https://travis-ci.org/appzcoder/crud-generator.svg)
4 | [](https://packagist.org/packages/appzcoder/crud-generator)
5 | [](https://packagist.org/packages/appzcoder/crud-generator)
6 | [](https://packagist.org/packages/appzcoder/crud-generator)
7 |
8 | This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless development of your applications.
9 |
10 | ## Requirements
11 | Laravel >= 8.0
12 | PHP >= 8.0.0
13 |
14 | ## Installation
15 | ```
16 | composer require appzcoder/crud-generator --dev
17 | ```
18 |
19 | ## Documentation
20 | Go through to the [detailed documentation](doc#readme)
21 |
22 | ## Screencast
23 |
24 | [](https://www.youtube.com/watch?v=K2G3kMQtY5Y)
25 |
26 | #### If you're still looking for easier one then try this [Admin Panel](https://github.com/appzcoder/laravel-admin)
27 |
28 | ## Author
29 |
30 | [Sohel Amin](http://sohelamin.com) :email: [Email Me](mailto:sohelamincse@gmail.com)
31 |
32 | ## License
33 |
34 | This project is licensed under the MIT License - see the [License File](LICENSE) for details
35 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "appzcoder/crud-generator",
3 | "license": "MIT",
4 | "description": "Laravel CRUD Generator",
5 | "keywords": [
6 | "laravel",
7 | "crud",
8 | "crud generator",
9 | "laravel crud generator",
10 | "api generator"
11 | ],
12 | "authors": [
13 | {
14 | "name": "Sohel Amin",
15 | "email": "sohelamincse@gmail.com",
16 | "homepage": "http://www.appzcoder.com"
17 | }
18 | ],
19 | "require": {
20 | "php": "^8.0",
21 | "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
22 | "laravel/breeze": "^1.10|^2.0"
23 | },
24 | "require-dev": {
25 | "mockery/mockery": "^1.0",
26 | "phpunit/phpunit": "^5.7|^8.0|^9.0",
27 | "orchestra/testbench": "^3.3|^4.0|^5.0"
28 | },
29 | "autoload": {
30 | "psr-4": {
31 | "Appzcoder\\CrudGenerator\\": "src/"
32 | },
33 | "classmap": [
34 | "tests"
35 | ]
36 | },
37 | "extra": {
38 | "laravel": {
39 | "providers": [
40 | "Appzcoder\\CrudGenerator\\CrudGeneratorServiceProvider"
41 | ]
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/config/crudgenerator.php:
--------------------------------------------------------------------------------
1 | false,
6 |
7 | /*
8 | |--------------------------------------------------------------------------
9 | | Crud Generator Template Stubs Storage Path
10 | |--------------------------------------------------------------------------
11 | |
12 | | Here you can specify your custom template path for the generator.
13 | |
14 | */
15 |
16 | 'path' => base_path('resources/crud-generator/'),
17 |
18 | /**
19 | * Columns number to show in view's table.
20 | */
21 | 'view_columns_number' => 3,
22 |
23 | /**
24 | * Delimiter for template vars
25 | */
26 | 'custom_delimiter' => ['%%', '%%'],
27 |
28 | /*
29 | |--------------------------------------------------------------------------
30 | | Dynamic templating
31 | |--------------------------------------------------------------------------
32 | |
33 | | Here you can specify your customs templates for the generator.
34 | | You can set new templates or delete some templates if you do not want them.
35 | | You can also choose which values are passed to the views and you can specify a custom delimiter for all templates
36 | |
37 | | Those values are available :
38 | |
39 | | formFields
40 | | formFieldsHtml
41 | | varName
42 | | crudName
43 | | crudNameCap
44 | | crudNameSingular
45 | | primaryKey
46 | | modelName
47 | | modelNameCap
48 | | viewName
49 | | routePrefix
50 | | routePrefixCap
51 | | routeGroup
52 | | formHeadingHtml
53 | | formBodyHtml
54 | |
55 | |
56 | */
57 | 'dynamic_view_template' => [
58 | 'index' => ['formHeadingHtml', 'formBodyHtml', 'crudName', 'crudNameCap', 'modelName', 'viewName', 'routeGroup', 'primaryKey'],
59 | 'form' => ['formFieldsHtml'],
60 | 'create' => ['crudName', 'crudNameCap', 'modelName', 'modelNameCap', 'viewName', 'routeGroup', 'viewTemplateDir'],
61 | 'edit' => ['crudName', 'crudNameSingular', 'crudNameCap', 'modelNameCap', 'modelName', 'viewName', 'routeGroup', 'primaryKey', 'viewTemplateDir'],
62 | 'show' => ['formHeadingHtml', 'formBodyHtml', 'formBodyHtmlForShowView', 'crudName', 'crudNameSingular', 'crudNameCap', 'modelName', 'viewName', 'routeGroup', 'primaryKey'],
63 | /*
64 | * Add new stubs templates here if you need to, like action, datatable...
65 | * custom_template needs to be activated for this to work
66 | */
67 | ]
68 |
69 |
70 | ];
71 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # Documentation
2 |
3 | This documentation will guide you to generate your stuffs for your application. Let's begin!
4 |
5 | ## Getting Started
6 |
7 | 1. [Installation](installation.md)
8 | 2. [Configuration](configuration.md)
9 | 3. [Usage](usage.md)
10 | 4. [Fields](fields.md)
11 | 5. [Options](options.md)
12 | 6. [Templates](templates.md)
13 |
--------------------------------------------------------------------------------
/doc/configuration.md:
--------------------------------------------------------------------------------
1 | ## Configuration
2 |
3 | You will find a configuration file located at `config/crudgenerator.php`
4 |
5 | ### Custom Template
6 |
7 | When you want to use your own custom template files, then you should turn it on and it will use the files from `resources/crud-generator/`
8 |
9 | ```php
10 | 'custom_template' => false,
11 | ```
12 |
13 | ### Path
14 |
15 | You can change your template path easily, the default path is `resources/crud-generator/`.
16 |
17 | ```php
18 | 'path' => base_path('resources/crud-generator/'),
19 | ```
20 |
21 | ### View Columns
22 |
23 | When generating CRUD or the views, the generator will assume the column number to show for the CRUD grid or detail automatically from the config. You can change it.
24 |
25 | ```php
26 | 'view_columns_number' => 3,
27 | ```
28 |
29 | ### Custom Delimiter
30 |
31 | Set your delimiter which you use for your template vars. The default delimiter is `%%` in everywhere.
32 |
33 | ```php
34 | 'custom_delimiter' => ['%%', '%%'],
35 | ```
36 | Note: You should use the delimiter same as yours template files.
37 |
38 | ### View Template Vars
39 |
40 | This configuration will help you to use any custom template vars in the views `index`, `form`, `create`, `edit`, `show`
41 |
42 | ```php
43 | 'dynamic_view_template' => [],
44 | ```
45 |
46 | [← Back to index](README.md)
47 |
--------------------------------------------------------------------------------
/doc/fields.md:
--------------------------------------------------------------------------------
1 | ## Supported Fields
2 |
3 | You can use any of the fields from the list.
4 |
5 | ### Form Field Types:
6 |
7 | * text
8 | * textarea
9 | * password
10 | * email
11 | * number
12 | * date
13 | * datetime
14 | * time
15 | * radio
16 | * select
17 | * file
18 |
19 | ### Migration Field Types:
20 |
21 | * string
22 | * char
23 | * varchar
24 | * date
25 | * datetime
26 | * time
27 | * timestamp
28 | * text
29 | * mediumtext
30 | * longtext
31 | * json
32 | * jsonb
33 | * binary
34 | * integer
35 | * bigint
36 | * mediumint
37 | * tinyint
38 | * smallint
39 | * boolean
40 | * decimal
41 | * double
42 | * float
43 | * enum
44 |
45 | [← Back to index](README.md)
46 |
--------------------------------------------------------------------------------
/doc/installation.md:
--------------------------------------------------------------------------------
1 | ## Installation
2 |
3 | To get started, you should add the `appzcoder/crud-generator` Composer dependency to your project:
4 | ```
5 | composer require appzcoder/crud-generator --dev
6 | ```
7 | Once the package is installed, you should publish its assets using the `vendor:publish` Artisan command:
8 | ```
9 | php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider"
10 | ```
11 | Before you begin, it's important to install the Laravel Breeze package with the Blade template, as there is a dependency on it.
12 | ```
13 | php artisan breeze:install
14 |
15 | php artisan migrate
16 | npm install
17 | npm run dev
18 | ```
19 |
20 | [← Back to index](README.md)
21 |
--------------------------------------------------------------------------------
/doc/options.md:
--------------------------------------------------------------------------------
1 | ## Options
2 |
3 | ### CRUD Options:
4 |
5 | | Option | Description |
6 | | --- | --- |
7 | | `--fields` | The field names for the form. e.g. ```--fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}; user_id#integer#unsigned'``` |
8 | | `--fields_from_file` | Fields from a JSON file. e.g. `--fields_from_file="/path/to/fields.json"` |
9 | | `--validations` | Validation rules for the fields "col_name#rules_set" e.g. ` "title#min:10|max:30|required" ` - See https://laravel.com/docs/master/validation#available-validation-rules |
10 | | `--controller-namespace` | The namespace of the controller - sub directories will be created |
11 | | `--model-namespace` | The namespace that the model will be placed in - directories will be created |
12 | | `--pk` | The name of the primary key |
13 | | `--pagination` | The amount of models per page for index pages |
14 | | `--indexes` | The fields to add an index to. append "#unique" to a field name to add a unique index. Create composite fields by separating fieldnames with a pipe (` --indexes="title,field1|field2#unique" ` will create normal index on title, and unique composite on fld1 and fld2) |
15 | | `--foreign-keys` | Any foreign keys for the table. e.g. `--foreign-keys="user_id#id#users#cascade"` where user_id is the column name, id is the name of the field on the foreign table, users is the name of the foreign table, and cascade is the operation 'ON DELETE' together with 'ON UPDATE' |
16 | | `--relationships` | The relationships for the model. e.g. `--relationships="comments#hasMany#App\Comment"` in the format |
17 | | `--route` | Include Crud route to routes.php? yes or no |
18 | | `--route-group` | Prefix of the route group |
19 | | `--view-path` | The name of the view path |
20 | | `--form-helper` | Helper for the form. eg. `--form-helper=blade`, `--form-helper=custom-template` |
21 | | `--localize` | Allow to localize. e.g. localize=yes |
22 | | `--locales` | Locales language type. e.g. locals=en |
23 | | `--soft-deletes` | Include soft deletes fields. eg. `--soft-deletes=yes` |
24 |
25 |
26 | ### Controller Options:
27 |
28 | | Option | Description |
29 | | --- | --- |
30 | | `--crud-name` | The name of the crud. e.g. ```--crud-name="post"``` |
31 | | `--model-name` | The name of the model. e.g. ```--model-name="Post"``` |
32 | | `--model-namespace` | The namespace of the model. e.g. ```--model-namespace="Custom\Namespace\Post"``` |
33 | | `--controller-namespace` | The namespace of the controller. e.g. ```--controller-namespace="Http\Controllers\Client"``` |
34 | | `--view-path` | The name of the view path |
35 | | `--fields` | The field names for the form. e.g. ```--fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}; user_id#integer#unsigned'``` |
36 | | `--validations` | Validation rules for the fields "col_name#rules_set" e.g. ``` "title#min:10|max:30|required" ``` - See https://laravel.com/docs/master/validation#available-validation-rules |
37 | | `--route-group` | Prefix of the route group |
38 | | `--pagination` | The amount of models per page for index pages |
39 | | `--force` | Overwrite already existing controller. |
40 |
41 | ### View Options:
42 |
43 | | Option | Description |
44 | | --- | --- |
45 | | `--fields` | The field names for the form. e.g. ```--fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}; user_id#integer#unsigned'``` |
46 | | `--view-path` | The name of the view path |
47 | | `--route-group` | Prefix of the route group |
48 | | `--pk` | The name of the primary key |
49 | | `--validations` | Validation rules for the form "col_name#rules_set" e.g. ``` "title#min:10|max:30|required" ``` - See https://laravel.com/docs/master/validation#available-validation-rules |
50 | | `--form-helper` | Helper for the form. eg. `--form-helper=blade`, `--form-helper=custom-template` |
51 | | `--custom-data` | Some additional values to use in the crud. |
52 | | `--localize` | Allow to localize. e.g. localize=yes |
53 |
54 | ### Model Options:
55 |
56 | | Option | Description |
57 | | --- | --- |
58 | | `--table` | The name of the table |
59 | | `--fillable` | The name of the view path |
60 | | `--relationships` | The relationships for the model. e.g. `--relationships="comments#hasMany#App\Comment"` in the format |
61 | | `--pk` | The name of the primary key |
62 | | `--soft-deletes` | Include soft deletes fields. eg. `--soft-deletes=yes` |
63 |
64 | ### Migration Options:
65 |
66 | | Option | Description |
67 | | --- | --- |
68 | | `--schema` | The name of the schema |
69 | | `--indexes` | The fields to add an index to. append "#unique" to a field name to add a unique index. Create composite fields by separating fieldnames with a pipe (` --indexes="title,field1|field2#unique" ` will create normal index on title, and unique composite on fld1 and fld2) |
70 | | `--foreign-keys` | Any foreign keys for the table. e.g. `--foreign-keys="user_id#id#users#cascade"` where user_id is the column name, id is the name of the field on the foreign table, users is the name of the foreign table, and cascade is the operation 'ON DELETE' together with 'ON UPDATE' |
71 | | `--pk` | The name of the primary key |
72 | | `--soft-deletes` | Include soft deletes fields. eg. `--soft-deletes=yes` |
73 |
74 | ### Lang Options:
75 |
76 | | Option | Description |
77 | | --- | --- |
78 | | `--fields` | The field names for the form. e.g. ```--fields='title#string; content#text``` |
79 | | `--locales` | Locales language type. e.g. locals=en |
80 |
81 | ### API CRUD Options:
82 |
83 | | Option | Description |
84 | | --- | --- |
85 | | `--fields` | The field names for the form. e.g. ```--fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}; user_id#integer#unsigned'``` |
86 | | `--fields_from_file` | Fields from a JSON file. e.g. `--fields_from_file="/path/to/fields.json"` |
87 | | `--validations` | Validation rules for the fields "col_name#rules_set" e.g. ` "title#min:10|max:30|required" ` - See https://laravel.com/docs/master/validation#available-validation-rules |
88 | | `--controller-namespace` | The namespace of the controller - sub directories will be created |
89 | | `--model-namespace` | The namespace that the model will be placed in - directories will be created |
90 | | `--pk` | The name of the primary key |
91 | | `--pagination` | The amount of models per page for index pages |
92 | | `--indexes` | The fields to add an index to. append "#unique" to a field name to add a unique index. Create composite fields by separating fieldnames with a pipe (` --indexes="title,field1|field2#unique" ` will create normal index on title, and unique composite on fld1 and fld2) |
93 | | `--foreign-keys` | Any foreign keys for the table. e.g. `--foreign-keys="user_id#id#users#cascade"` where user_id is the column name, id is the name of the field on the foreign table, users is the name of the foreign table, and cascade is the operation 'ON DELETE' together with 'ON UPDATE' |
94 | | `--relationships` | The relationships for the model. e.g. `--relationships="comments#hasMany#App\Comment"` in the format |
95 | | `--route` | Include Crud route to routes.php? yes or no |
96 | | `--route-group` | Prefix of the route group |
97 | | `--soft-deletes` | Include soft deletes fields. eg. `--soft-deletes=yes` |
98 |
99 | ### API Controller Options:
100 |
101 | | Option | Description |
102 | | --- | --- |
103 | | `--crud-name` | The name of the crud. e.g. ```--crud-name="post"``` |
104 | | `--model-name` | The name of the model. e.g. ```--model-name="Post"``` |
105 | | `--model-namespace` | The namespace of the model. e.g. ```--model-namespace="Custom\Namespace\Post"``` |
106 | | `--controller-namespace` | The namespace of the controller. e.g. ```--controller-namespace="Http\Controllers\Client"``` |
107 | | `--validations` | Validation rules for the fields "col_name#rules_set" e.g. ``` "title#min:10|max:30|required" ``` - See https://laravel.com/docs/master/validation#available-validation-rules |
108 | | `--pagination` | The amount of models per page for index pages |
109 | | `--force` | Overwrite already existing controller. |
110 |
111 | [← Back to index](README.md)
112 |
--------------------------------------------------------------------------------
/doc/templates.md:
--------------------------------------------------------------------------------
1 | ## Custom Templates
2 |
3 | The package allows user to extensively customize or use own templates.
4 |
5 | ### All Templates
6 |
7 | To customize or change the template, you need to follow these steps:
8 |
9 | 1. Just make sure you've published all assets of this package. If you didn't just run this command.
10 | ```php
11 | php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider"
12 | ```
13 | 2. To override the default template with yours, turn on `custom_template` option in the `config/crudgenerator.php` file.
14 | ```php
15 | 'custom_template' => true,
16 | ```
17 |
18 | 3. Now you can customize everything from this `resources/crud-generator/` directory.
19 |
20 | 4. Even if you need to use any custom variable just add those in the `config/crudgenerator.php` file.
21 |
22 | ### Form Helper
23 |
24 | You can use any form template for your forms. In order to do that, you just need to mention the helper package name while generating the main CRUD or views with this option `--form-helper`. This generator use `blade` as default helper.
25 |
26 | To use the any other form helper, you need to follow these steps:
27 |
28 | 1. Make sure you've installed & configured the desire helper package.
29 |
30 | 2. For use custom helper template, you should turn on `custom_template` option in the `config/crudgenerator.php` file.
31 |
32 | 3. Now put your files into `resources/crud-generator/views/` directory. Suppose your helper is `custom-template` then you should create a directory as `resources/crud-generator/views/custom-template`. You can also copy the template files from other helper directory, then modify as yours.
33 |
34 | 4. You're ready to generate the CRUD with your helper.
35 | ```
36 | php artisan crud:generate Posts --fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}' --view-path=admin --controller-namespace=Admin --route-group=admin --form-helper=custom-template
37 | ```
38 |
39 | [← Back to index](README.md)
40 |
--------------------------------------------------------------------------------
/doc/usage.md:
--------------------------------------------------------------------------------
1 | ## Usage
2 |
3 | ### CRUD Command
4 |
5 | ```
6 | php artisan crud:generate Posts --fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}' --view-path=admin --controller-namespace=App\\Http\\Controllers\\Admin --route-group=admin --form-helper=blade
7 | ```
8 |
9 | #### CRUD fields from a JSON file:
10 |
11 | ```json
12 | {
13 | "fields": [
14 | {
15 | "name": "title",
16 | "type": "string"
17 | },
18 | {
19 | "name": "content",
20 | "type": "text"
21 | },
22 | {
23 | "name": "category",
24 | "type": "select",
25 | "options": {
26 | "technology": "Technology",
27 | "tips": "Tips",
28 | "health": "Health"
29 | }
30 | },
31 | {
32 | "name": "user_id",
33 | "type": "integer#unsigned"
34 | }
35 | ],
36 | "foreign_keys": [
37 | {
38 | "column": "user_id",
39 | "references": "id",
40 | "on": "users",
41 | "onDelete": "cascade"
42 | }
43 | ],
44 | "relationships": [
45 | {
46 | "name": "user",
47 | "type": "belongsTo",
48 | "class": "App\\Models\\User"
49 | }
50 | ],
51 | "validations": [
52 | {
53 | "field": "title",
54 | "rules": "required|max:10"
55 | }
56 | ]
57 | }
58 | ```
59 |
60 | ```
61 | php artisan crud:generate Posts --fields_from_file="/path/to/fields.json" --view-path=admin --controller-namespace=App\\Http\\Controllers\\Admin --route-group=admin --form-helper=blade
62 | ```
63 |
64 | ### Other Commands
65 |
66 | For controller:
67 |
68 | ```
69 | php artisan crud:controller PostsController --crud-name=posts --model-name=Post --view-path="directory" --route-group=admin
70 | ```
71 |
72 | For model:
73 |
74 | ```
75 | php artisan crud:model Post --fillable="['title', 'body']"
76 | ```
77 |
78 | For migration:
79 |
80 | ```
81 | php artisan crud:migration posts --schema="title#string; body#text"
82 | ```
83 |
84 | For view:
85 |
86 | ```
87 | php artisan crud:view posts --fields="title#string; body#text" --view-path="directory" --route-group=admin
88 | --form-helper=blade
89 | ```
90 |
91 | By default, the generator will attempt to append the crud route to your ```Route``` file. If you don't want the route added, you can use this option ```--route=no```.
92 |
93 | After creating all resources, run migrate command. *If necessary, include the route for your crud as well.*
94 |
95 | ```
96 | php artisan migrate
97 | ```
98 |
99 | If you chose not to add the crud route in automatically (see above), you will need to include the route manually.
100 | ```php
101 | Route::resource('posts', 'PostsController');
102 | ```
103 |
104 | ### API Commands
105 |
106 | For api crud:
107 |
108 | ```
109 | php artisan crud:api Posts --fields='title#string; content#text' --controller-namespace=Api
110 | ```
111 |
112 | For api controller:
113 |
114 | ```
115 | php artisan crud:api-controller Api\\PostsController --crud-name=posts --model-name=Post
116 | ```
117 |
118 | ### File Upload
119 | If you want to add file on a CRUD just mention the field type as `file` eg. ```--fields='avatar#file;```
120 |
121 | All the files will upload to `storage\app\public\uploads` directory. So you should symbolic the storage dir to public access.
122 | ```
123 | php artisan storage:link
124 | ```
125 | Get your uploaded file as:
126 | ```php
127 | $file = Storage::disk('public')->get('uploads\filename.jpg');
128 | ```
129 |
130 | [← Back to index](README.md)
131 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | ./tests
19 |
20 |
21 |
22 |
23 | ./src
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/publish/views/admin/dashboard.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |