Skip to content

Commit

Permalink
Update the default template to Bootstrap 5.3 and drop support for lar…
Browse files Browse the repository at this point in the history
…avel-collective
  • Loading branch information
MikeAlhayek authored Jan 24, 2024
2 parents b502395 + 68bb0f3 commit e4734f6
Show file tree
Hide file tree
Showing 180 changed files with 1,125 additions and 3,421 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ An intelligent code generator for Laravel framework that will save you time! Thi

For full documentation and live demo please visit <a href="https://crestapps.com/laravel-code-generator/docs/2.3" target="_blank" title="Laravel Code Generator Documentation">CrestApps.com</a>

**Note: ** The available documentation is for versions <= 2.2. The documentation for vertion 2.3+ is very similar with some exceptions. Please review the <a href="https://github.com/CrestApps/laravel-code-generator/blob/master/CHANGELOG.md" title="ChangeLog">Change Log</a> to get a list of the changes.
**Note: ** The available documentation is for versions <= 2.2. The documentation for version 2.3+ is very similar with some exceptions. Please review the <a href="https://github.com/CrestApps/laravel-code-generator/blob/master/CHANGELOG.md" title="ChangeLog">Change Log</a> to get a list of the changes.

## Features

Expand All @@ -22,7 +22,7 @@ For full documentation and live demo please visit <a href="https://crestapps.com
<li>Allows you to save the fields in a JSON file and recreate resources when the business needs changes.</li>
<li>Utilizes JSON based resource-file to allow you to define your resources. Resource-file allows you to easily regenerate the resource at any time even when the business rules change.</li>
<li>Create standard CRUD controllers with simple or form-request validation.</li>
<li>Customizable view’s templates to enable you to change the standard look and feel of your application.</li>
<li>Customizable view templates to enable you to change the standard look and feel of your application.</li>
<li>Create model with relations.</li>
<li>Create named routes with and without group.</li>
<li>Create standard CRUD views.</li>
Expand All @@ -34,34 +34,34 @@ For full documentation and live demo please visit <a href="https://crestapps.com
<li>Client-side validation.</li>
<li>File uploading handling.</li>
<li>Auto store multiple-response in the database.</li>
<li>Create form-request to clean up your controller and increase your code reusability.</li>
<li>Create form-request to clean up your controller and increase your code re-usability.</li>
<li>Create view's layouts with and without client-side validation.</li>
<li>Change the template at run time to generate different views.</li>
<li>Ability to generate views with and without Laravel-Collective.</li>
<li>Nicely handles any date, time or datetime field.</li>
<li>Nicely handles any date, time or DateTime field.</li>
<li>Auto handles any boolean field.</li>
<li>Very easy to use with lots of documentation.</li>
</ul>

## Installation

1. To download this package into your laravel project, use the command-line to execute the following command
1. To download this package into your Laravel project, use the command-line to execute the following command

```
composer require crestapps/laravel-code-generator --dev
```

2. **(You may skip this step when using Laravel >= 5.5)** To bootstrap the packages into your project while using command-line only, open the app/Providers/AppServiceProvider.php file in your project. Then, add the following code to the register() method.

Add the following line to bootstrap laravel-code-generator to the framework.
Add the following line to bootstrap `laravel-code-generator` to the framework.

```
if ($this->app->runningInConsole()) {
$this->app->register('CrestApps\CodeGenerator\CodeGeneratorServiceProvider');
}
```

> A layout is required for the default views! The code generator allows you to create a layout using the command-line. Of cource you can use your own layout. You'll only need to include [CSS bootstrap framework](http://getbootstrap.com/ "CSS bootstrap framework") in your layout for the default templates to work properly. Additionally, you can chose to you design your own templetes using a different or no css framework.
> A layout is required for the default views! The code generator allows you to create a layout using the command-line. Of course you can use your own layout. You'll only need to include [CSS bootstrap framework](http://getbootstrap.com/ "CSS bootstrap framework") in your layout for the default templates to work properly. Additionally, you can chose to you design your own templates using a different or no css framework.
## Lessons
Checkout our channel on <a href="https://www.youtube.com/channel/UCkEd0nOoRf3o0ahspAu7Y9w/videos" target="_blank" title="CrestApps YouTube Channel">YouTube.com</a>
Expand Down Expand Up @@ -93,6 +93,12 @@ Checkout our channel on <a href="https://www.youtube.com/channel/UCkEd0nOoRf3o0a
<li>php artisan create:api-scaffold [model-name]</li>
<li>php artisan create:api-controller [model-name]</li>
<li>php artisan create:api-resources [model-name]</li>
</ul>
</li>
<li>
<strong>API Documentations commands</strong>
<ul>
<li>php artisan api-docs:scaffold [model-name]</li>
<li>php artisan api-doc:create-controller [model-name]</li>
<li>php artisan api-doc:create-view [model-name]</li>
</ul>
Expand Down Expand Up @@ -250,4 +256,3 @@ The following example assumes that we are trying to create a CRUD called <var>As
## License

"Laravel Code Generator" is an open-sourced software licensed under the <a href="https://opensource.org/licenses/MIT" target="_blank" title="MIT license">MIT license</a>

78 changes: 36 additions & 42 deletions config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -161,7 +147,7 @@
|--------------------------------------------------------------------------
|
*/
'api_docs_controller_path' => 'Http/Controllers/ApiDocs',
'api_docs_controller_path' => 'Http/Controllers',

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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' => [
Expand Down Expand Up @@ -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',
],
],
[
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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()"
Expand All @@ -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"
Expand Down Expand Up @@ -570,7 +568,6 @@
'delete' => [
'text' => 'Delete [% model_name_title %]',
'template' => 'delete_model',
'in-function-with-collective' => true,
],
'edit' => [
'text' => 'Edit [% model_name_title %]',
Expand All @@ -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.',
Expand Down Expand Up @@ -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' => [
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 %].',
Expand Down Expand Up @@ -929,7 +923,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' => [
Expand Down
4 changes: 2 additions & 2 deletions config/laravel-code-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/CodeGeneratorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public function boot()
$this->publishes([
$dir . 'templates/default' => $this->codeGeneratorBase('templates/default'),
], 'default-template');

// publish the defaultcollective-template
$this->publishes([
$dir . 'templates/default-collective' => $this->codeGeneratorBase('templates/default-collective'),
], 'default-collective-template');
}

/**
Expand Down Expand Up @@ -69,7 +64,7 @@ public function register()
'CrestApps\CodeGenerator\Commands\ApiDocs\CreateApiDocsControllerCommand',
'CrestApps\CodeGenerator\Commands\ApiDocs\CreateApiDocsScaffoldCommand',
'CrestApps\CodeGenerator\Commands\ApiDocs\CreateApiDocsViewCommand',
'CrestApps\CodeGenerator\Commands\Resources\ResourceFileFromDatabaseAllCommand'
'CrestApps\CodeGenerator\Commands\Resources\ResourceFileFromDatabaseAllCommand'
];

if (Helpers::isNewerThanOrEqualTo()) {
Expand Down
Loading

0 comments on commit e4734f6

Please sign in to comment.