Skip to content

Commit f34731e

Browse files
author
Stefano Manfredini
committed
Merge branch 'master' of https://github.com/CrestApps/laravel-code-generator into proposed-changes
* 'master' of https://github.com/CrestApps/laravel-code-generator: Add casting to the model Add labels fields-file, improves the foreign relations Add function to set values like Auth::Id(). and add config to define common relations
2 parents 1f62104 + a83d3c4 commit f34731e

26 files changed

+988
-359
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "crestapps/laravel-code-generator",
33
"license": "MIT",
44
"description": "A clean code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages or request-forms! It is extremely flexible and customizable to cover many use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.",
5-
"version": "v1.3.0",
5+
"version": "v2.0.0",
66
"keywords": [
77
"laravel","crud","crud generator",
88
"laravel crud generator","laravel crud builder",

config/.php_cs.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"7.1.1","version":"2.3.1:v2.3.1#d5257f7433bb490299c4f300d95598fd911a8ab0","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"codegenerator.php":295300723}}
1+
{"php":"7.1.1","version":"2.3.1:v2.3.1#d5257f7433bb490299c4f300d95598fd911a8ab0","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"codegenerator.php":1292351656}}

config/codegenerator.php

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -161,55 +161,71 @@
161161
| to use. Here is description of the definition array
162162
|
163163
| "name" will be used to create the relation method's name.
164-
| "model" the foreign model.
164+
| "type" will be used to set the relation type
165+
| "params" the parameters to use for the "type" relation.
165166
| "field" the field on the foreign model to use as display name.
166167
| "on-create" sets a value to use when this model is created. If your using an authentication
167168
| system such as laravel build in authentication. you can automaticly set
168169
| the user Id who created the model by setting this value to 'Auth::Id();'.
169170
| "on-update" sets a value to use when this model is update.
170-
| "on-delete" sets a value to use when this model is soft-deleted.
171171
|
172172
*/
173-
'common_foreign_keys' => [
174-
'owner_id' => [
175-
'name' => 'owner',
176-
'model' => 'App\\User',
177-
'field' => 'name',
178-
'on-create' => null,
179-
'on-update' => null,
180-
'on-delete' => null
173+
174+
"common_foreign_keys" => [
175+
"owner_id" => [
176+
"name" => "owner",
177+
"type" => "belongsTo",
178+
"params" => [
179+
"App\\User",
180+
"owner_id"
181+
],
182+
"field" => "name",
183+
"on-store" => null,
184+
"on-update" => null,
181185
],
182-
'operator_id' => [
183-
'name' => 'operator',
184-
'model' => 'App\\User',
185-
'field' => 'name',
186-
'on-create' => null,
187-
'on-update' => null,
188-
'on-delete' => null
186+
"operator_id" => [
187+
"name" => "operator",
188+
"type" => "belongsTo",
189+
"params" => [
190+
"App\\User",
191+
"operator_id"
192+
],
193+
"field" => "name",
194+
"on-store" => null,
195+
"on-update" => null,
189196
],
190-
'created_by' => [
191-
'name' => 'creator',
192-
'model' => 'App\\User',
193-
'field' => 'name',
194-
'on-create' => 'Auth::Id();',
195-
'on-update' => null,
196-
'on-delete' => null
197+
"author_id" => [
198+
"name" => "author",
199+
"type" => "belongsTo",
200+
"params" => [
201+
"App\\User",
202+
"author_id"
203+
],
204+
"field" => "name",
205+
"on-store" => null,
206+
"on-update" => null,
197207
],
198-
'updated_by' => [
199-
'name' => 'updator',
200-
'model' => 'App\\User',
201-
'field' => 'name',
202-
'on-create' => null,
203-
'on-update' => 'Auth::Id();',
204-
'on-delete' => null
208+
"created_by" => [
209+
"name" => "creator",
210+
"type" => "belongsTo",
211+
"params" => [
212+
"App\\User",
213+
"created_by"
214+
],
215+
"field" => "name",
216+
"on-store" => "Illuminate\Support\Facades\Auth::Id();",
217+
"on-update" => null,
205218
],
206-
'deleted_by' => [
207-
'name' => 'deleator',
208-
'model' => 'App\\User',
209-
'field' => 'name',
210-
'on-create' => null,
211-
'on-update' => null,
212-
'on-delete' => 'Auth::Id();'
219+
"updated_by" => [
220+
"name" => "updator",
221+
"type" => "belongsTo",
222+
"params" => [
223+
"App\\User",
224+
"created_by"
225+
],
226+
"field" => "name",
227+
"on-store" => null,
228+
"on-update" => "Illuminate\Support\Facades\Auth::Id();",
213229
]
214230
],
215231

src/Commands/.php_cs.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"7.1.1","version":"2.3.1:v2.3.1#d5257f7433bb490299c4f300d95598fd911a8ab0","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"CreateControllerCommand.php":2028451951,"CreateLanguageCommand.php":143920987,"FieldsFileCreateCommand.php":-1927885825}}
1+
{"php":"7.1.1","version":"2.3.1:v2.3.1#d5257f7433bb490299c4f300d95598fd911a8ab0","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"CreateControllerCommand.php":-832128993,"CreateLanguageCommand.php":143920987,"FieldsFileCreateCommand.php":-280774643,"CreateModelCommand.php":-1845010254}}

0 commit comments

Comments
 (0)