diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9a14922 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: malhayek +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..801f638 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,34 @@ +on: + workflow_dispatch: + push: + branches: + - master + paths: + - docs/** +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + + - name: Install dependencies + run: npm install + working-directory: ./docs + + - name: Build site + run: npm run build + working-directory: ./docs + + - name: Deploy Files + uses: SamKirkland/FTP-Deploy-Action@v4.3.4 + with: + server: ${{ secrets.FTP_HOST }} + username: ${{ secrets.FTP_USERNAME }} + password: ${{ secrets.FTP_PASSWORD }} + local-dir: ./docs/build/ + diff --git a/.gitignore b/.gitignore index 9990b78..c8725b0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ .DS_Store vendor/ composer.lock + +.vscode/ +.node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index f10a84b..9856258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - The `create:routes` command now has a new option `without-route-clause` which will create the routes without `there` clause for the id. It may be used when the primary key is not an integer. Additionally, the options `--for-api` and `--api-version` have been added to add support for created api-based routes. - added command to create api-resource with/without collection when using Laravel 5.5+. - The `create:api-scaffold` command have been added to allow you to create resources for the api. - - The user is no longer required to publish the default templates. This is much better step to prevent upgrade braking when the template are updated during a patch release. The user should publish templates only if he/she want to modify it and rename it. **IMPORTANT** Delete existing default and default-collective templates from the folders from the default publish path of your project. + - The user is no longer required to publish the default templates. This is much better step to prevent upgrade braking when the template are updated during a patch release. The user should publish templates only if he/she want to modify it and rename it. **IMPORTANT** Delete existing `default` templates from the folders from the default publish path of your project. - The user no longer have to publish resource to install the package! One line only is required to install the package on laravel 5.5+ (i.e, composer require crestapps/laravel-code-generator --dev) - **IMPORTANT**: delete the the `codegenerator.php` file from your config folder, then rename the `codegenerator_custom.php` file to `laravel-code-generator.php`. Alternatively, you can delete both `codegenerator.php` and `codegenerator_custom.php` - Added `--model-extends` option to the create:model command to allow the use to extend a custom default base class. diff --git a/README.md b/README.md index 28d2e3a..cfa46db 100644 --- a/README.md +++ b/README.md @@ -5,47 +5,37 @@ An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application. -For full documentation and live demo please visit CrestApps.com - -**Note: ** The available documentation is for versions <= 2.2. The documentation for vertion 2.3+ is very similar with some exceptions. Please review the Change Log to get a list of the changes. +For full documentation and live demo please visit CrestApps.com ## Features -
Then it will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views and the routes!
- -## What's new? -* Release Notes +s * Upgrade Guide ## License "Laravel Code Generator" is an open-sourced software licensed under the MIT license - diff --git a/config/default.php b/config/default.php index 659e5e3..2f0ba79 100644 --- a/config/default.php +++ b/config/default.php @@ -30,20 +30,6 @@ */ 'templates_path' => 'resources/laravel-code-generator/templates', - /* - |-------------------------------------------------------------------------- - | Array of templates that should be generated with Laravel-Collective. - |-------------------------------------------------------------------------- - | - | If you want to generate code by using laravel-collective, you must first - | install the package. Then add the tamplate name that should be using - | Laravel-Collective extensions when generating code. - | - */ - 'laravel_collective_templates' => [ - 'default-collective', - ], - /* |-------------------------------------------------------------------------- | The default path of where the uploaded files live. @@ -59,7 +45,7 @@ /* |-------------------------------------------------------------------------- - | The default output format for datetime fields. + | The default output format for DateTime fields. |-------------------------------------------------------------------------- | | This output format can also be changed at the field level using the @@ -70,10 +56,10 @@ /* |-------------------------------------------------------------------------- - | The default path of where the json resource-files are located. + | The default path of where the JSON resource-files are located. |-------------------------------------------------------------------------- | - | In this path, you can create json file to import the resources from. + | In this path, you can create JSON file to import the resources from. | */ 'resource_file_path' => 'resources/laravel-code-generator/sources', @@ -161,7 +147,7 @@ |-------------------------------------------------------------------------- | */ - 'api_docs_controller_path' => 'Http/Controllers/ApiDocs', + 'api_docs_controller_path' => 'Http/Controllers', /* |-------------------------------------------------------------------------- @@ -231,15 +217,15 @@ /* |-------------------------------------------------------------------------- - | Patterns to use to generate the html placeholders. + | Patterns to use to generate the HTML placeholders. |-------------------------------------------------------------------------- | | When creating the fields, the code generator follows a pattern to generate - | placeholders for the html code. Here you can define which html-types should + | placeholders for the HTML code. Here you can define which html-types should | the generator create placeholder for. Also, you can define how would you like | the text to read when no placeholder is assigned. | - | The follwowing templates can be used to. assuming the field name is owner_name + | The following templates can be used to. assuming the field name is owner_name | [% field_name %] <=> "owner name" | [% field_name_sentence %] <=> "Owner name" | [% field_name_plural %] <=> "owner names" @@ -268,11 +254,11 @@ | Key phrases that are will be used to determine if a field should have a relation. |-------------------------------------------------------------------------- | - | When creating resources from existing database, the codegenerator scans - | the field's name for a mattching pattern. When found, these field are considered + | When creating resources from existing database, the code generator scans + | the field's name for a matching pattern. When found, these field are considered | foreign keys even when the database does not have a foreign constraints. | Here you can specify patterns to help the generator understand your - | database naming convension. + | database naming conversion. | */ 'common_key_patterns' => [ @@ -338,10 +324,23 @@ ], ], [ - 'match' => ['picture', 'file', 'photo', 'avatar'], + 'match' => ['picture', 'photo', 'avatar', 'image'], + 'set' => [ + 'is-on-index' => false, + 'html-type' => 'file', + 'data-type' => 'string', + 'data-type-params' => [255], + 'validation' => 'image', + ], + ], + [ + 'match' => ['file', 'document', 'attachment*'], 'set' => [ 'is-on-index' => false, 'html-type' => 'file', + 'data-type' => 'string', + 'data-type-params' => [255], + 'validation' => 'file', ], ], [ @@ -373,7 +372,7 @@ ], ], [ - 'match' => ['created_at', 'updated_at', 'deleted_at'], + 'match' => ['created_at', 'updated_at', 'deleted_at', 'modified_at'], 'set' => [ 'data-type' => 'datetime', 'is-on-form' => false, @@ -464,7 +463,7 @@ /* |-------------------------------------------------------------------------- - | A string to postfix the api-resource name with. + | A string to post fix the api-resource name with. |-------------------------------------------------------------------------- | | If you don't like to post fix the api-resource with "Resource" you can @@ -475,7 +474,7 @@ /* |-------------------------------------------------------------------------- - | A string to postfix the collection-api-resource name with. + | A string to post fix the collection-api-resource name with. |-------------------------------------------------------------------------- | | If you don't like to post fix the collection-api-resource with "Collection" @@ -495,7 +494,7 @@ /* |-------------------------------------------------------------------------- - | A string to postfix the form-request name with. + | A string to post fix the form-request name with. |-------------------------------------------------------------------------- | | If you don't like to post fix the form-request with "FormRequest" you can @@ -506,7 +505,7 @@ /* |-------------------------------------------------------------------------- - | Defining non-english or irregular plurals + | Defining non-English or irregular plurals |-------------------------------------------------------------------------- | | The code-generator heavily uses Laravel helpers "str_plural()" @@ -533,10 +532,9 @@ | The "key" of the array is the value to be used in the locale files. | The "text" key of the sub array, is the string to display in the view or add to the locale files. | The "template" key of the sub array, is the string to be use in the view for replacement. - | The "in-function-with-collective" key of the sub array, tell the generator that, | this string would be used in a function or not. | - | The follwowing templates can be used. Assuming the model name is AssetCategory + | The following templates can be used. Assuming the model name is AssetCategory | [% model_name %] <=> "asset category" | [% model_name_sentence %] <=> "Asset category" | [% model_name_plural %] <=> "asset categories" @@ -570,7 +568,6 @@ 'delete' => [ 'text' => 'Delete [% model_name_title %]', 'template' => 'delete_model', - 'in-function-with-collective' => true, ], 'edit' => [ 'text' => 'Edit [% model_name_title %]', @@ -587,17 +584,14 @@ 'add' => [ 'text' => 'Add', 'template' => 'add', - 'in-function-with-collective' => true, ], 'update' => [ 'text' => 'Update', 'template' => 'update', - 'in-function-with-collective' => true, ], 'confirm_delete' => [ 'text' => 'Click Ok to delete [% model_name_title %].', 'template' => 'confirm_delete', - 'in-function-with-collective' => true, ], 'none_available' => [ 'text' => 'No [% model_name_plural_title %] Available.', @@ -658,7 +652,7 @@ 'template' => 'this_parameter_is_an_http_header', ], 'request_was_successful' => [ - 'text' => 'Request was successfull.', + 'text' => 'Request was successfully.', 'template' => 'request_was_successful', ], 'boolean_title' => [ @@ -807,7 +801,7 @@ | Here you can define labels to be used when creating the api-documentation. | You can define how would you like the text to be generated. | - | The follwowing templates can be used. Assuming the model name is AssetCategory + | The following templates can be used. Assuming the model name is AssetCategory | [% model_name %] <=> "asset category" | [% model_name_sentence %] <=> "Asset category" | [% model_name_plural %] <=> "asset categories" @@ -840,12 +834,12 @@ 'the_total_of_available_pages' => 'The total of the available pages.', 'store_route_description' => 'Create new [% model_name %].', 'store_route_response_description' => 'The API\'s response will be JSON based data. The JSON object will be structured as follow', - 'update_route_description' => 'Update existsing [% model_name %].', + 'update_route_description' => 'Update existing [% model_name %].', 'update_route_response_description' => 'The API\'s response will be JSON based data. The JSON object will be structured as follow', - 'show_route_description' => 'Retrieve existsing [% model_name %].', + 'show_route_description' => 'Retrieve existing [% model_name %].', 'show_route_response_description' => 'The API\'s response will be JSON based data. The JSON object will be structured as follow', 'the_id_of_model_to_retrieve' => 'The unique id of the [% model_name %] to retrieve', - 'destroy_route_description' => 'Delete existsing [% model_name %].', + 'destroy_route_description' => 'Delete existing [% model_name %].', 'destroy_route_response_description' => 'The API\'s response will be JSON based data. The JSON object will be structured as follow', 'the_id_of_model_to_delete' => 'The id of the [% model_name %] to delete.', 'general_description' => 'Allows you to list, create, edit, show and delete [% model_name_plural %].', @@ -898,6 +892,7 @@ 'macaddress' => 'macAddress', 'mediuminteger' => 'mediumInteger', 'mediumint' => 'mediumInteger', + 'tinytext' => 'tinyText', 'mediumtext' => 'mediumText', 'smallInteger' => 'smallInteger', 'smallint' => 'smallInteger', @@ -929,7 +924,7 @@ | Eloquent method to html-type mapping. |-------------------------------------------------------------------------- | - | This is the mapping used to convert database-column into html field + | This is the mapping used to convert database-column into HTML field | */ 'eloquent_type_to_html_type' => [ diff --git a/config/laravel-code-generator.php b/config/laravel-code-generator.php index a71cbbd..4eccd9a 100644 --- a/config/laravel-code-generator.php +++ b/config/laravel-code-generator.php @@ -7,14 +7,14 @@ | CodeGenerator config overrides |-------------------------------------------------------------------------- | - | It is a good idea to sperate your configuration form the code-generator's + | It is a good idea to separate your configuration form the code-generator's | own configuration. This way you won't lose any settings/preference | you have when upgrading to a new version of the package. | | Additionally, you will always know any the configuration difference between | the default config than your own. | - | To override the setting that is found in the codegenerator.php file, you'll + | To override the setting that is found in the 'config/default.php' file, you'll | need to create identical key here with a different value | | IMPORTANT: When overriding an option that is an array, the configurations diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..b2d6de3 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,20 @@ +# Dependencies +/node_modules + +# Production +/build + +# Generated files +.docusaurus +.cache-loader + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..0c6c2c2 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,41 @@ +# Website + +This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. + +### Installation + +``` +$ yarn +``` + +### Local Development + +``` +$ yarn start +``` + +This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. + +### Build + +``` +$ yarn build +``` + +This command generates static content into the `build` directory and can be served using any static contents hosting service. + +### Deployment + +Using SSH: + +``` +$ USE_SSH=true yarn deploy +``` + +Not using SSH: + +``` +$ GIT_USER=docs
directory.
+ >
+ ),
+ },
+ {
+ title: 'Powered by React',
+ Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
+ description: (
+ <>
+ Extend or customize your website layout by reusing React. Docusaurus can
+ be extended while reusing the same header and footer.
+ >
+ ),
+ },
+];
+
+function Feature({Svg, title, description}) {
+ return (
+ {description}
+{siteConfig.tagline}
+[% the_user_does_not_have_permission_to_access_the_requested_resource %]
-success | -[% boolean_title %] | -[% indicate_whether_the_request_was_successful_or_not %] | -
error | -[% array_of_strings %] | -[% the_error_message %] | -
[% the_requested_model_does_not_exists %]
-success | -[% boolean_title %] | -[% indicate_whether_the_request_was_successful_or_not %] | -
error | -[% array_of_strings %] | -[% the_error_message %] | -
[% the_request_failed_validation %]
-success | -[% boolean_title %] | -[% indicate_whether_the_request_was_successful_or_not %] | -
errors | -[% array_of_strings %] | -[% list_of_the_invalid_errors %] | -
[% parameter_name_title %] | -[% data_type_title %] | -[% parameter_type_title %] | -[% description_title %] | - @if($showValidation) -[% validation_title %] | - @endif -
---|---|---|---|---|
[% model_name %] | -[% primary_key_type_title %] | -[% path_title %] | -[% the_id_of_the_model %] | - @if($showValidation) -- [% validation_rule_required %] - | - @endif -
[% parameter_name_title %] | -[% data_type_title %] | -[% parameter_type_title %] | -[% description_title %] | -
---|
[% name_title %] | -[% type_title %] | -[% description_title %] | -
---|
[% request_was_successful %]
-success | -[% boolean_title %] | -[% indicate_whether_the_request_was_successful_or_not %] | -
message | -[% string_title %] | -[% the_success_message %] | -
data | -[% array_title %] | -[% the_key_is_the_model_property_and_the_value_is_the_model_value %] | -
[% index_route_response_description %]
- - -[% request_was_successful %]
-success | -[% boolean_title %] | -Was the request successful or not. | -||||||||||||||||||||||||
message | -[% string_title %] | -[% the_success_message %] | -||||||||||||||||||||||||
data | -[% array_title %] | -- [% the_key_is_the_model_property_and_the_value_is_the_model_value %] - | -||||||||||||||||||||||||
links | -[% array_title %] | -
-
|
- ||||||||||||||||||||||||
meta | -[% array_title %] | -
-
|
-
[% store_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - @include('[% path_to_view_home %]failed-validation') - [% include_failed_authentication_for_authorized_request %] - -[% update_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - @include('[% path_to_view_home %]failed-validation') - [% include_failed_authentication_for_authorized_request %] - -[% parameter_name_title %] | -[% data_type_title %] | -[% parameter_type_title %] | -[% description_title %] | -
---|---|---|---|
[% model_name %] | -[% integer_title %] | -[% path_title %] | -[% the_id_of_model_to_retrieve %] | -
[% show_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - [% include_failed_authentication_for_authorized_request %] - -[% parameter_name_title %] | -[% data_type_title %] | -[% parameter_type_title %] | -[% description_title %] | -
---|---|---|---|
[% model_name %] | -[% integer_title %] | -[% path_title %] | -[% the_id_of_model_to_delete %] | -
[% destroy_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - [% include_failed_authentication_for_authorized_request %] - -[% field_name_title %] | -[% field_type_title %] | -[% description_title %] | -
---|
:message
') !!} \ No newline at end of file diff --git a/templates/default-collective/form-input-field.blade.stub b/templates/default-collective/form-input-field.blade.stub deleted file mode 100644 index d37139b..0000000 --- a/templates/default-collective/form-input-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ - {!! Form::[% field_type %]('[% field_name %]',[% field_value %], ['class' => 'form-control[% css_class %]',[% min_length %][% max_length %][% min_value %][% max_value %][% required_field %][% placeholder %][% step %] ]) !!} \ No newline at end of file diff --git a/templates/default-collective/form-input-wrapper.blade.stub b/templates/default-collective/form-input-wrapper.blade.stub deleted file mode 100644 index 23c42f3..0000000 --- a/templates/default-collective/form-input-wrapper.blade.stub +++ /dev/null @@ -1,8 +0,0 @@ - -- |
---|
-
- {!! Form::open([
- 'method' =>'DELETE',
- 'route' => ['[% destroy_route_name %]', $[% model_name_singular_variable %]->[% primary_key %]],
- 'style' => 'display: inline;',
- ]) !!}
-
- [% primary_key %] ) }}" class="btn btn-info" title="[% show_model %]">
-
-
- [% primary_key %] ) }}" class="btn btn-primary" title="[% edit_model %]">
-
-
-
- {!! Form::button('',
- [
- 'type' => 'submit',
- 'class' => 'btn btn-danger',
- 'title' => [% delete_model %],
- 'onclick' => 'return confirm("' . [% confirm_delete %] . '")'
- ])
- !!}
-
- {!! Form::close() !!}
- |
-
[% index_route_description %]
[% index_route_response_description %]
- - -[% request_was_successful %]
-success | -[% boolean_title %] | -Was the request successful or not. | -||||||||||||||||||||||||
message | -[% string_title %] | -[% the_success_message %] | -||||||||||||||||||||||||
data | -[% array_title %] | -- [% the_key_is_the_model_property_and_the_value_is_the_model_value %] - | -||||||||||||||||||||||||
links | -[% array_title %] | -
-
|
- ||||||||||||||||||||||||
meta | -[% array_title %] | -
-
|
-
[% index_route_response_description %]
+ + +[% request_was_successful %]
+success | +[% boolean_title %] | +Was the request successful or not. | +||||||||||||||||||||||||
message | +[% string_title %] | +[% the_success_message %] | +||||||||||||||||||||||||
data | +[% array_title %] | ++ [% the_key_is_the_model_property_and_the_value_is_the_model_value %] + | +||||||||||||||||||||||||
links | +[% array_title %] | +
+
|
+ ||||||||||||||||||||||||
meta | +[% array_title %] | +
+
|
+
[% store_route_description %]
[% store_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - @include('[% path_to_view_home %]failed-validation') - [% include_failed_authentication_for_authorized_request %] - -[% store_route_response_description %]
+ -[% update_route_description %]
+[% update_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - @include('[% path_to_view_home %]failed-validation') - [% include_failed_authentication_for_authorized_request %] +[% update_route_response_description %]
+ + + @include('[% path_to_view_home %]retrieved') + @include('[% path_to_view_home %]failed-to-retrieve') + @include('[% path_to_view_home %]failed-validation') + [% include_failed_authentication_for_authorized_request %] -[% show_route_description %]
[% parameter_name_title %] | -[% data_type_title %] | -[% parameter_type_title %] | -[% description_title %] | -
---|---|---|---|
[% model_name %] | -[% integer_title %] | -[% path_title %] | -[% the_id_of_model_to_retrieve %] | -
[% show_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - [% include_failed_authentication_for_authorized_request %] - -[% parameter_name_title %] | +[% data_type_title %] | +[% parameter_type_title %] | +[% description_title %] | +
---|---|---|---|
[% model_name %] | +[% integer_title %] | +[% path_title %] | +[% the_id_of_model_to_retrieve %] | +
[% show_route_response_description %]
+ + + @include('[% path_to_view_home %]retrieved') + @include('[% path_to_view_home %]failed-to-retrieve') + [% include_failed_authentication_for_authorized_request %] +[% destroy_route_description %]
[% parameter_name_title %] | -[% data_type_title %] | -[% parameter_type_title %] | -[% description_title %] | -
---|---|---|---|
[% model_name %] | -[% integer_title %] | -[% path_title %] | -[% the_id_of_model_to_delete %] | -
[% destroy_route_response_description %]
- - - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - [% include_failed_authentication_for_authorized_request %] - -[% parameter_name_title %] | +[% data_type_title %] | +[% parameter_type_title %] | +[% description_title %] | +
---|---|---|---|
[% model_name %] | +[% integer_title %] | +[% path_title %] | +[% the_id_of_model_to_delete %] | +
[% destroy_route_response_description %]
+ + + @include('[% path_to_view_home %]retrieved') + @include('[% path_to_view_home %]failed-to-retrieve') + [% include_failed_authentication_for_authorized_request %] -[% field_name_title %] | -[% field_type_title %] | -[% description_title %] | -
---|
[% field_name_title %] | +[% field_type_title %] | +[% description_title %] | +
---|