|
8 | 8 | |-------------------------------------------------------------------------- |
9 | 9 | | |
10 | 10 | | Here you change the stub templates to use when generating code. |
11 | | - | You can duplicate the "default" template folder |
12 | | - | and call it what ever template your like "ex. skyblue". |
| 11 | + | You can duplicate the 'default' template folder |
| 12 | + | and call it what ever template your like 'ex. skyblue'. |
13 | 13 | | Now, you can change the stubs to have your own templates generated. |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | IMPORTANT: It is not recomended to modify the default template, rather create a new template. |
17 | | - | If you modify the default template and then executed "php artisan vendor:publish" command, |
| 17 | + | If you modify the default template and then executed 'php artisan vendor:publish' command, |
18 | 18 | | it will override the default template causing you to lose your modification. |
19 | 19 | | |
20 | 20 | */ |
|
36 | 36 | |-------------------------------------------------------------------------- |
37 | 37 | | |
38 | 38 | | If you want to generate code by using laravel-collective, you must first |
39 | | - | install the package. Then add the tamplate name that should be using |
| 39 | + | install the package. Then add the tamplate name that should be using |
40 | 40 | | Laravel-Collective extensions when generating code. |
41 | 41 | */ |
42 | 42 | 'laravel_collective_templates' => [ |
|
54 | 54 |
|
55 | 55 | /* |
56 | 56 | |-------------------------------------------------------------------------- |
57 | | - | The default format for the datetime output |
| 57 | + | The default output format for datetime fields. |
58 | 58 | |-------------------------------------------------------------------------- |
59 | 59 | | |
60 | 60 | | |
|
63 | 63 |
|
64 | 64 | /* |
65 | 65 | |-------------------------------------------------------------------------- |
66 | | - | The default path of where the field json files are located |
| 66 | + | The default path of where the field json files are located. |
67 | 67 | |-------------------------------------------------------------------------- |
68 | 68 | | |
69 | 69 | | In this path, you can create json file to import the fields from. |
|
113 | 113 | */ |
114 | 114 | 'common_header_patterns' => ['title','name','label','header'], |
115 | 115 |
|
116 | | - /* |
117 | | - |-------------------------------------------------------------------------- |
118 | | - | Key phrases that are will be used to determine if a field should be a primary key. |
119 | | - |-------------------------------------------------------------------------- |
120 | | - */ |
121 | | - 'common_id_patterns' => ['id'], |
122 | | - |
123 | | - /* |
124 | | - |-------------------------------------------------------------------------- |
125 | | - | Patterns to use to determine "datetime" fields if date-type is not provided |
126 | | - |-------------------------------------------------------------------------- |
127 | | - | |
128 | | - | If the date-type for a field is not, the codegenerator scanns the field's name |
129 | | - | for a matching pattern. If the name matches any of the set pattern, the the |
130 | | - | field's type will automaticly be set to datetime. |
131 | | - | |
132 | | - */ |
133 | | - 'common_datetime_patterns' => ['*_at','*_date'], |
134 | | - |
135 | | - /* |
136 | | - |-------------------------------------------------------------------------- |
137 | | - | Patterns to use to determine "boolean" fields if date-type is not provided |
138 | | - |-------------------------------------------------------------------------- |
139 | | - | |
140 | | - | If the date-type for a field is not, the codegenerator scanns the field's name |
141 | | - | for a matching pattern. If the name matches any of the set pattern, the the |
142 | | - | field's type will automaticly be set to boolean. |
143 | | - | |
144 | | - */ |
145 | | - 'common_boolean_patterns' => ['is_*','has_*'], |
146 | | - |
147 | 116 | /* |
148 | 117 | |-------------------------------------------------------------------------- |
149 | 118 | | Key phrases that are will be used to determine if a field should have a relation. |
150 | 119 | |-------------------------------------------------------------------------- |
151 | 120 | | |
152 | 121 | | When creating resources from existing database, the codegenerator scans |
153 | | - | the field's name for a mattching pattern. When found, these field are considred |
| 122 | + | the field's name for a mattching pattern. When found, these field are considred |
154 | 123 | | foreign keys even if the database does not have a foreign constraints. |
155 | 124 | | Here you can specify patterns to help the generator understand your |
156 | 125 | | database naming convension. |
157 | 126 | | |
158 | 127 | */ |
159 | 128 | 'common_key_patterns' => ['*_id','*_by'], |
160 | | - |
| 129 | + |
161 | 130 | /* |
162 | 131 | |-------------------------------------------------------------------------- |
163 | | - | Common foreign keys definitions |
| 132 | + | Patterns to use to pre-set field's properties. |
164 | 133 | |-------------------------------------------------------------------------- |
165 | 134 | | |
166 | | - | The code generator uses "common_key_patterns" array to scan the field name |
167 | | - | for matching patterns to determine if a field should be considred foreign key. |
168 | | - | "common_foreign_keys" allows you to set global configuration for common foreign key. |
169 | | - | Each key in the array represents the field name. The value is an array of definitions |
170 | | - | to use. Here is description of the definition array |
171 | | - | |
172 | | - | "name" will be used to create the relation method's name. |
173 | | - | "type" will be used to set the relation type |
174 | | - | "params" the parameters to use for the "type" relation. |
175 | | - | "field" the field on the foreign model to use as display name. |
176 | | - | "on-create" sets a value to use when this model is created. If your using an authentication |
177 | | - | system such as laravel build in authentication. you can automaticly set |
178 | | - | the user Id who created the model by setting this value to 'Auth::Id();'. |
179 | | - | "on-update" sets a value to use when this model is update. |
| 135 | + | To make constructing fields easy, the codegenerator scans the field's name |
| 136 | + | for a matching pattern. If the name matches any of the set pattern, the the |
| 137 | + | field's properties will be preset. defining pattern will save you from having |
| 138 | + | to re-define the properties for common fields. |
180 | 139 | | |
181 | 140 | */ |
182 | | - |
183 | | - "common_foreign_keys" => [ |
184 | | - "owner_id" => [ |
185 | | - "name" => "owner", |
186 | | - "type" => "belongsTo", |
187 | | - "params" => [ |
188 | | - "App\\User", |
189 | | - "owner_id" |
190 | | - ], |
191 | | - "field" => "name", |
192 | | - "on-store" => null, |
193 | | - "on-update" => null, |
| 141 | + 'common_definitions' => [ |
| 142 | + [ |
| 143 | + 'match' => 'id', |
| 144 | + 'set' => [ |
| 145 | + 'is-on-form' => false, |
| 146 | + 'is-on-index' => false, |
| 147 | + 'is-on-show' => false, |
| 148 | + 'html-type' => 'hidden', |
| 149 | + 'data-type' => 'integer', |
| 150 | + 'is-primary' => true, |
| 151 | + 'is-auto-increment' => true, |
| 152 | + 'is-nullable' => false, |
| 153 | + 'is-unsigned' => true, |
| 154 | + ] |
| 155 | + ], |
| 156 | + [ |
| 157 | + 'match' => ['*_id','*_by'], |
| 158 | + 'set' => [ |
| 159 | + 'data-type' => 'integer', |
| 160 | + 'html-type' => 'select', |
| 161 | + 'is-nullable' => false, |
| 162 | + 'is-unsigned' => true, |
| 163 | + ] |
| 164 | + ], |
| 165 | + [ |
| 166 | + 'match' => ['*_at'], |
| 167 | + 'set' => [ |
| 168 | + 'data-type' => 'dateTime' |
| 169 | + ] |
| 170 | + ], |
| 171 | + [ |
| 172 | + 'match' => ['created_at','updated_at','deleted_at'], |
| 173 | + 'set' => [ |
| 174 | + 'data-type' => 'dateTime', |
| 175 | + 'is-on-form' => false, |
| 176 | + 'is-on-index' => false, |
| 177 | + 'is-on-show' => true, |
| 178 | + ] |
| 179 | + ], |
| 180 | + [ |
| 181 | + 'match' => ['*_date'], |
| 182 | + 'set' => [ |
| 183 | + 'data-type' => 'date', |
| 184 | + 'date-format' => 'm/d/Y' |
| 185 | + ] |
| 186 | + ], |
| 187 | + [ |
| 188 | + 'match' => ['is_*','has_*'], |
| 189 | + 'set' => [ |
| 190 | + 'data-type' => 'boolean', |
| 191 | + 'html-type' => 'checkbox', |
| 192 | + 'is-nullable' => false |
| 193 | + ] |
| 194 | + ], |
| 195 | + [ |
| 196 | + 'match' => 'owner_id', |
| 197 | + 'set' => [ |
| 198 | + 'title' => 'Owner', |
| 199 | + 'data-type' => 'integer', |
| 200 | + 'foreign-relation' => [ |
| 201 | + 'name' => 'owner', |
| 202 | + 'type' => 'belongsTo', |
| 203 | + 'params' => [ |
| 204 | + 'App\\User', |
| 205 | + 'owner_id' |
| 206 | + ], |
| 207 | + 'field' => 'name' |
| 208 | + ], |
| 209 | + 'on-store' => null, |
| 210 | + 'on-update' => null |
| 211 | + ] |
194 | 212 | ], |
195 | | - "operator_id" => [ |
196 | | - "name" => "operator", |
197 | | - "type" => "belongsTo", |
198 | | - "params" => [ |
199 | | - "App\\User", |
200 | | - "operator_id" |
201 | | - ], |
202 | | - "field" => "name", |
203 | | - "on-store" => null, |
204 | | - "on-update" => null, |
| 213 | + [ |
| 214 | + 'match' => 'operator_id', |
| 215 | + 'set' => [ |
| 216 | + 'title' => 'Operator', |
| 217 | + 'data-type' => 'integer', |
| 218 | + 'foreign-relation' => [ |
| 219 | + 'name' => 'operator', |
| 220 | + 'type' => 'belongsTo', |
| 221 | + 'params' => [ |
| 222 | + 'App\\User', |
| 223 | + 'operator_id' |
| 224 | + ], |
| 225 | + 'field' => 'name' |
| 226 | + ], |
| 227 | + 'on-store' => null, |
| 228 | + 'on-update' => null |
| 229 | + ] |
205 | 230 | ], |
206 | | - "author_id" => [ |
207 | | - "name" => "author", |
208 | | - "type" => "belongsTo", |
209 | | - "params" => [ |
210 | | - "App\\User", |
211 | | - "author_id" |
212 | | - ], |
213 | | - "field" => "name", |
214 | | - "on-store" => null, |
215 | | - "on-update" => null, |
| 231 | + [ |
| 232 | + 'match' => 'author_id', |
| 233 | + 'set' => [ |
| 234 | + 'title' => 'Author', |
| 235 | + 'data-type' => 'integer', |
| 236 | + 'foreign-relation' => [ |
| 237 | + 'name' => 'author', |
| 238 | + 'type' => 'belongsTo', |
| 239 | + 'params' => [ |
| 240 | + 'App\\User', |
| 241 | + 'author_id' |
| 242 | + ], |
| 243 | + 'field' => 'name' |
| 244 | + ], |
| 245 | + 'on-store' => null, |
| 246 | + 'on-update' => null |
| 247 | + ] |
216 | 248 | ], |
217 | | - "created_by" => [ |
218 | | - "name" => "creator", |
219 | | - "type" => "belongsTo", |
220 | | - "params" => [ |
221 | | - "App\\User", |
222 | | - "created_by" |
223 | | - ], |
224 | | - "field" => "name", |
225 | | - "on-store" => "Illuminate\Support\Facades\Auth::Id();", |
226 | | - "on-update" => null, |
| 249 | + [ |
| 250 | + 'match' => 'created_by', |
| 251 | + 'set' => [ |
| 252 | + 'title' => 'Creator', |
| 253 | + 'data-type' => 'integer', |
| 254 | + 'foreign-relation' => [ |
| 255 | + 'name' => 'creator', |
| 256 | + 'type' => 'belongsTo', |
| 257 | + 'params' => [ |
| 258 | + 'App\\User', |
| 259 | + 'created_by' |
| 260 | + ], |
| 261 | + 'field' => 'name' |
| 262 | + ], |
| 263 | + 'on-store' => 'Illuminate\Support\Facades\Auth::Id();', |
| 264 | + 'on-update' => null |
| 265 | + ] |
227 | 266 | ], |
228 | | - "updated_by" => [ |
229 | | - "name" => "updator", |
230 | | - "type" => "belongsTo", |
231 | | - "params" => [ |
232 | | - "App\\User", |
233 | | - "created_by" |
234 | | - ], |
235 | | - "field" => "name", |
236 | | - "on-store" => null, |
237 | | - "on-update" => "Illuminate\Support\Facades\Auth::Id();", |
| 267 | + [ |
| 268 | + 'match' => ['updated_by','modified_by'], |
| 269 | + 'set' => [ |
| 270 | + 'title' => 'Updater', |
| 271 | + 'data-type' => 'integer', |
| 272 | + 'foreign-relation' => [ |
| 273 | + 'name' => 'updater', |
| 274 | + 'type' => 'belongsTo', |
| 275 | + 'params' => [ |
| 276 | + 'App\\User', |
| 277 | + 'updated_by' |
| 278 | + ], |
| 279 | + 'field' => 'name' |
| 280 | + ], |
| 281 | + 'on-store' => null, |
| 282 | + 'on-update' => 'Illuminate\Support\Facades\Auth::Id();' |
| 283 | + ] |
238 | 284 | ] |
239 | 285 | ], |
240 | 286 |
|
|
300 | 346 |
|
301 | 347 | /* |
302 | 348 | |-------------------------------------------------------------------------- |
303 | | - | Eloquent method to html-type mapping |
| 349 | + | Eloquent method to html-type mapping. |
304 | 350 | |-------------------------------------------------------------------------- |
305 | 351 | | |
306 | 352 | | This is the mapping used to convert database-column into html field |
|
0 commit comments