generathor-laravel 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +57 -3
  2. package/dist/configuration.d.ts +6 -0
  3. package/dist/configuration.js +15 -6
  4. package/dist/{template.d.ts → generator.d.ts} +1 -0
  5. package/dist/{template.js → generator.js} +81 -21
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.js +3 -1
  8. package/dist/laravel11.d.ts +7 -0
  9. package/dist/laravel11.js +41 -0
  10. package/dist/laravel12.d.ts +7 -0
  11. package/dist/laravel12.js +39 -0
  12. package/package.json +2 -2
  13. package/templates/eloquent/laravel11/user.handlebars +67 -0
  14. package/templates/eloquent/laravel12/user.handlebars +60 -0
  15. package/templates/others/laravel12/base-controller.handlebars +54 -0
  16. package/templates/others/laravel12/pagination.handlebars +106 -0
  17. package/templates/views/laravel11/menu.handlebars +31 -0
  18. package/templates/views/laravel12/banner.handlebars +48 -0
  19. package/templates/views/laravel12/breadcrumbs.handlebars +21 -0
  20. package/templates/views/laravel12/edit.handlebars +31 -0
  21. package/templates/views/laravel12/form.handlebars +103 -0
  22. package/templates/views/laravel12/index.handlebars +171 -0
  23. package/templates/views/laravel12/loader.handlebars +6 -0
  24. package/templates/views/laravel12/menu.handlebars +21 -0
  25. package/templates/views/laravel12/modal.handlebars +36 -0
  26. package/templates/views/laravel12/record-input.handlebars +90 -0
  27. package/templates/views/laravel12/relation-item.handlebars +170 -0
  28. package/templates/views/laravel12/relation-list.handlebars +189 -0
  29. package/templates/views/laravel12/show.handlebars +124 -0
  30. package/templates/views/laravel12/tabs.handlebars +16 -0
  31. package/templates/views/menu.handlebars +0 -39
  32. /package/templates/others/{base-controller.handlebars → laravel11/base-controller.handlebars} +0 -0
  33. /package/templates/views/{breadcrumbs.handlebars → laravel11/breadcrumbs.handlebars} +0 -0
  34. /package/templates/views/{edit.handlebars → laravel11/edit.handlebars} +0 -0
  35. /package/templates/views/{form.handlebars → laravel11/form.handlebars} +0 -0
  36. /package/templates/views/{index.handlebars → laravel11/index.handlebars} +0 -0
  37. /package/templates/views/{loader.handlebars → laravel11/loader.handlebars} +0 -0
  38. /package/templates/views/{modal.handlebars → laravel11/modal.handlebars} +0 -0
  39. /package/templates/views/{record-input.handlebars → laravel11/record-input.handlebars} +0 -0
  40. /package/templates/views/{relation-item.handlebars → laravel11/relation-item.handlebars} +0 -0
  41. /package/templates/views/{relation-list.handlebars → laravel11/relation-list.handlebars} +0 -0
  42. /package/templates/views/{show.handlebars → laravel11/show.handlebars} +0 -0
  43. /package/templates/views/{tabs.handlebars → laravel11/tabs.handlebars} +0 -0
package/README.md CHANGED
@@ -145,6 +145,44 @@ module.exports = {
145
145
  };
146
146
  ```
147
147
 
148
+ You can optionally use the preconfigured generator with the following "shortcuts".
149
+
150
+ ```js
151
+ const { Laravel11 } = require('generathor-laravel');
152
+
153
+ const laravel = Laravel11.jetstreamEloquentModels();
154
+ ```
155
+
156
+ ```js
157
+ const { Laravel11 } = require('generathor-laravel');
158
+
159
+ const laravel = Laravel11.eloquentModels();
160
+ ```
161
+
162
+ ```js
163
+ const { Laravel11 } = require('generathor-laravel');
164
+
165
+ const laravel = Laravel11.jetstreamCrud();
166
+ ```
167
+
168
+ ```js
169
+ const { Laravel12 } = require('generathor-laravel');
170
+
171
+ const laravel = Laravel12.starterKitEloquentModels();
172
+ ```
173
+
174
+ ```js
175
+ const { Laravel12 } = require('generathor-laravel');
176
+
177
+ const laravel = Laravel12.eloquentModels();
178
+ ```
179
+
180
+ ```js
181
+ const { Laravel12 } = require('generathor-laravel');
182
+
183
+ const laravel = Laravel12.starterKitCrud();
184
+ ```
185
+
148
186
  Then, run the following command:
149
187
 
150
188
  ```bash
@@ -162,26 +200,33 @@ Also, you need to install the following packages:
162
200
 
163
201
  * alpinejs
164
202
  * @alpinejs/collapse
203
+ * @alpinejs/mask
165
204
  * laravel-precognition-alpine
166
205
  * sweetalert2
206
+ * @fortawesome/fontawesome-free
207
+ * axios
167
208
 
168
209
  ```bash
169
- npm i -D alpinejs @alpinejs/collapse laravel-precognition-alpine sweetalert2
210
+ npm i -D alpinejs @alpinejs/collapse @alpinejs/mask laravel-precognition-alpine sweetalert2 @fortawesome/fontawesome-free axios
170
211
  ```
171
212
 
172
213
  File `app.js` must contain:
173
214
 
174
215
  ```js
175
216
  import Alpine from 'alpinejs';
176
- import collapse from '@alpinejs/collapse'
217
+ import collapse from '@alpinejs/collapse';
218
+ import mask from '@alpinejs/mask';
177
219
  import Precognition from 'laravel-precognition-alpine';
178
220
  import Swal from 'sweetalert2';
221
+ import axios from 'axios';// Laravel 11 import this by default in bootstrap.js
179
222
 
223
+ window.axios = axios;
180
224
  window.Alpine = Alpine;
181
225
  window.Swal = Swal;
182
226
 
183
227
  Alpine.plugin(Precognition);
184
228
  Alpine.plugin(collapse);
229
+ Alpine.plugin(mask);
185
230
  Alpine.start();
186
231
  ```
187
232
 
@@ -203,7 +248,7 @@ Route::prefix('manage')->group(function () {
203
248
 
204
249
  #### Set up your 'home' route
205
250
 
206
- You neet to set up your `home` route. You can change the home route reference in the `generathor.config.cjs` file.
251
+ You need to set up your `home` route. You can change the home route reference in the `generathor.config.cjs` file.
207
252
 
208
253
  ```php
209
254
  Route::get('/', function () {
@@ -286,7 +331,13 @@ if (typeof Livewire !== undefined) {
286
331
  Add the following code in `layout.blade.php` or in your layout:
287
332
 
288
333
  ```blade
334
+ <!-- LARAVEL 11 -->
335
+ <x-generathor.loader />
336
+ <x-banner /><!-- You can use this with laravel 11 + jetstream -->
337
+
338
+ <!-- LARAVEL 12 -->
289
339
  <x-generathor.loader />
340
+ <x-generathor.banner /><!-- Only needed with laravel 12 -->
290
341
  ```
291
342
 
292
343
  #### Set up header (optional)
@@ -312,6 +363,9 @@ You can modify settings in the `generathor.config.cjs` file.
312
363
  | `createChildModel` | `No` | boolean | true | Prevents overwriting the child class of a model, so you retain your custom changes. |
313
364
  | `createEloquentModelsOnly` | `No` | boolean | false | Creates only Eloquent models, skipping the generation of other files. |
314
365
  | `reference` | `No` | string | 'laravel-generathor' | Reference name used in templates. |
366
+ | `laravelVersion` | `No` | 11 or 12 | 12 | Laravel application version. |
367
+ | `createLaravel11UserModel` | `No` | boolean | false | Check if a custom laravel 11 user model is required. |
368
+ | `createLaravel12UserModel` | `No` | boolean | false | Check if a custom laravel 12 user model is required. |
315
369
  | `source` | `No` | string | 'db' | Reference to the Generathor source for database structure. |
316
370
  | `directory` | `No` | string | '.' | Directory path for the Laravel project. |
317
371
  | `homeRoute` | `No` | string | 'home' | Initial base route, used for redirection to the home page. |
@@ -1,6 +1,9 @@
1
1
  export type ConfigurationAttributes = {
2
+ laravelVersion?: 11 | 12;
2
3
  createChildModel?: boolean;
3
4
  createEloquentModelsOnly?: boolean;
5
+ createLaravel12UserModel?: boolean;
6
+ createLaravel11UserModel?: boolean;
4
7
  reference?: string;
5
8
  source?: string;
6
9
  directory?: string;
@@ -16,6 +19,9 @@ export declare class Configuration {
16
19
  constructor($attributes: ConfigurationAttributes);
17
20
  directory(): string;
18
21
  reference(): string;
22
+ laravelVersion(): 11 | 12;
23
+ createLaravel12UserModel(): boolean;
24
+ createLaravel11UserModel(): boolean;
19
25
  source(): string;
20
26
  homeRoute(): string;
21
27
  layout(): string;
@@ -11,6 +11,17 @@ class Configuration {
11
11
  reference() {
12
12
  return this.$attributes.reference || 'laravel-generathor';
13
13
  }
14
+ laravelVersion() {
15
+ return this.$attributes.laravelVersion || 12;
16
+ }
17
+ createLaravel12UserModel() {
18
+ var _a;
19
+ return (_a = this.$attributes.createLaravel12UserModel) !== null && _a !== void 0 ? _a : false;
20
+ }
21
+ createLaravel11UserModel() {
22
+ var _a;
23
+ return (_a = this.$attributes.createLaravel11UserModel) !== null && _a !== void 0 ? _a : false;
24
+ }
14
25
  source() {
15
26
  return this.$attributes.source || 'db';
16
27
  }
@@ -30,14 +41,12 @@ class Configuration {
30
41
  'Illuminate\\Database\\Eloquent\\Model');
31
42
  }
32
43
  createChildModel() {
33
- return typeof this.$attributes.createChildModel === 'undefined'
34
- ? true
35
- : this.$attributes.createChildModel;
44
+ var _a;
45
+ return (_a = this.$attributes.createChildModel) !== null && _a !== void 0 ? _a : true;
36
46
  }
37
47
  createEloquentModelsOnly() {
38
- return typeof this.$attributes.createEloquentModelsOnly === 'undefined'
39
- ? false
40
- : this.$attributes.createEloquentModelsOnly;
48
+ var _a;
49
+ return (_a = this.$attributes.createEloquentModelsOnly) !== null && _a !== void 0 ? _a : false;
41
50
  }
42
51
  }
43
52
  exports.Configuration = Configuration;
@@ -5,6 +5,7 @@ type GeneratorType = GeneratorForItem | GeneratorForCollection;
5
5
  type Templates = Record<string, GeneratorType>;
6
6
  export declare class LaravelGenerator {
7
7
  private $configuration;
8
+ private $viewFolder;
8
9
  constructor(configuration?: ConfigurationAttributes);
9
10
  private templateKey;
10
11
  private templateFile;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LaravelGenerator = void 0;
4
4
  const path_1 = require("path");
5
+ const fs_1 = require("fs");
5
6
  const generathor_1 = require("generathor");
6
7
  const configuration_1 = require("./configuration");
7
8
  const laravel_1 = require("./transformers/item/laravel");
@@ -18,10 +19,10 @@ const hasManyRelation_1 = require("./transformers/collection/hasManyRelation");
18
19
  const handlebars_1 = require("./helpers/handlebars");
19
20
  class LaravelGenerator {
20
21
  constructor(configuration) {
21
- if (!configuration) {
22
- configuration = {};
23
- }
22
+ configuration = configuration || {};
24
23
  this.$configuration = new configuration_1.Configuration(configuration);
24
+ this.$viewFolder =
25
+ this.$configuration.laravelVersion() == 12 ? 'laravel12' : 'laravel11';
25
26
  handlebars_1.HandlebarsHelper.configure();
26
27
  }
27
28
  templateKey(key) {
@@ -57,6 +58,7 @@ class LaravelGenerator {
57
58
  template: this.templateFile('eloquent/child'),
58
59
  source: this.$configuration.source(),
59
60
  directory: this.directory('/app/Models'),
61
+ overwriteFiles: false,
60
62
  prepareItems: (items) => items.map((item) => item.laravel.eloquent),
61
63
  fileName: (item) => item.model + '.php',
62
64
  });
@@ -100,56 +102,57 @@ class LaravelGenerator {
100
102
  fileName: (item) => item.class + '.php',
101
103
  });
102
104
  templates[this.templateKey('menu')] = new generathor_1.GeneratorForItem({
103
- template: this.templateFile('views/menu'),
105
+ template: this.templateFile(`views/${this.$viewFolder}/menu`),
104
106
  source: this.$configuration.source(),
105
107
  directory: this.directory('/resources/views/generathor'),
106
108
  prepareItems: (items) => new menu_1.Menu(items, this.$configuration).transform(),
107
109
  fileName: () => 'menu.blade.php',
108
110
  });
109
111
  templates[this.templateKey('base-controller')] = new generathor_1.GeneratorForItem({
110
- template: this.templateFile('others/base-controller'),
112
+ template: this.templateFile(`others/${this.$viewFolder}/base-controller`),
111
113
  source: this.$configuration.source(),
112
114
  directory: this.directory('/app/Http/Controllers/Generathor'),
115
+ overwriteFiles: false,
113
116
  prepareItems: (items) => new baseController_1.BaseController(items, this.$configuration).transform(),
114
117
  fileName: () => 'Controller.php',
115
118
  });
116
119
  templates[this.templateKey('create-form')] = new generathor_1.GeneratorForItem({
117
- template: this.templateFile('views/form'),
120
+ template: this.templateFile(`views/${this.$viewFolder}/form`),
118
121
  source: this.$configuration.source(),
119
122
  directory: this.directory('/resources/views/components/generathor'),
120
123
  prepareItems: (items) => items.map((item) => item.laravel.forms.create),
121
124
  fileName: (item) => item.context + '/create-form.blade.php',
122
125
  });
123
126
  templates[this.templateKey('filter-form')] = new generathor_1.GeneratorForItem({
124
- template: this.templateFile('views/form'),
127
+ template: this.templateFile(`views/${this.$viewFolder}/form`),
125
128
  source: this.$configuration.source(),
126
129
  directory: this.directory('/resources/views/components/generathor'),
127
130
  prepareItems: (items) => items.map((item) => item.laravel.forms.filter),
128
131
  fileName: (item) => item.context + '/filter-form.blade.php',
129
132
  });
130
133
  templates[this.templateKey('update-form')] = new generathor_1.GeneratorForItem({
131
- template: this.templateFile('views/form'),
134
+ template: this.templateFile(`views/${this.$viewFolder}/form`),
132
135
  source: this.$configuration.source(),
133
136
  directory: this.directory('/resources/views/components/generathor'),
134
137
  prepareItems: (items) => items.map((item) => item.laravel.forms.update),
135
138
  fileName: (item) => item.context + '/update-form.blade.php',
136
139
  });
137
140
  templates[this.templateKey('attach-form')] = new generathor_1.GeneratorForItem({
138
- template: this.templateFile('views/form'),
141
+ template: this.templateFile(`views/${this.$viewFolder}/form`),
139
142
  source: this.$configuration.source(),
140
143
  directory: this.directory('/resources/views/components/generathor'),
141
144
  prepareItems: (items) => new attachForm_1.AttachForm(items, this.$configuration).transform(),
142
145
  fileName: (item) => `${item.context}/attach-${item.contextFile}-form.blade.php`,
143
146
  });
144
147
  templates[this.templateKey('create-relation-form')] = new generathor_1.GeneratorForItem({
145
- template: this.templateFile('views/form'),
148
+ template: this.templateFile(`views/${this.$viewFolder}/form`),
146
149
  source: this.$configuration.source(),
147
150
  directory: this.directory('/resources/views/components/generathor'),
148
151
  prepareItems: (items) => new createRelationForm_1.CreateRelationForm(items, this.$configuration).transform(),
149
152
  fileName: (item) => `${item.context}/create-${item.contextFile}-form.blade.php`,
150
153
  });
151
154
  templates[this.templateKey('filter-relation-form')] = new generathor_1.GeneratorForItem({
152
- template: this.templateFile('views/form'),
155
+ template: this.templateFile(`views/${this.$viewFolder}/form`),
153
156
  source: this.$configuration.source(),
154
157
  directory: this.directory('/resources/views/components/generathor'),
155
158
  prepareItems: (items) => new filterRelationForm_1.FilterRelationForm(items, this.$configuration).transform(),
@@ -163,35 +166,35 @@ class LaravelGenerator {
163
166
  fileName: (item) => item.class + '.php',
164
167
  });
165
168
  templates[this.templateKey('index-view')] = new generathor_1.GeneratorForItem({
166
- template: this.templateFile('views/index'),
169
+ template: this.templateFile(`views/${this.$viewFolder}/index`),
167
170
  source: this.$configuration.source(),
168
171
  directory: this.directory('/resources/views/generathor'),
169
172
  prepareItems: (items) => items.map((item) => item.laravel.list),
170
173
  fileName: (item) => item.context + '/index.blade.php',
171
174
  });
172
175
  templates[this.templateKey('edit-view')] = new generathor_1.GeneratorForItem({
173
- template: this.templateFile('views/edit'),
176
+ template: this.templateFile(`views/${this.$viewFolder}/edit`),
174
177
  source: this.$configuration.source(),
175
178
  directory: this.directory('/resources/views/generathor'),
176
179
  prepareItems: (items) => items.map((item) => item.laravel.edit),
177
180
  fileName: (item) => item.context + '/edit.blade.php',
178
181
  });
179
182
  templates[this.templateKey('show-view')] = new generathor_1.GeneratorForItem({
180
- template: this.templateFile('views/show'),
183
+ template: this.templateFile(`views/${this.$viewFolder}/show`),
181
184
  source: this.$configuration.source(),
182
185
  directory: this.directory('/resources/views/generathor'),
183
186
  prepareItems: (items) => items.map((item) => item.laravel.show),
184
187
  fileName: (item) => item.context + '/show.blade.php',
185
188
  });
186
189
  templates[this.templateKey('relation-item-view')] = new generathor_1.GeneratorForItem({
187
- template: this.templateFile('views/relation-item'),
190
+ template: this.templateFile(`views/${this.$viewFolder}/relation-item`),
188
191
  source: this.$configuration.source(),
189
192
  directory: this.directory('/resources/views/generathor'),
190
193
  prepareItems: (items) => new belongsToRelation_1.BelongsToRelation(items, this.$configuration).transform(),
191
194
  fileName: (item) => `${item.context}/${item.relationContext}.blade.php`,
192
195
  });
193
196
  templates[this.templateKey('relation-list-view')] = new generathor_1.GeneratorForItem({
194
- template: this.templateFile('views/relation-list'),
197
+ template: this.templateFile(`views/${this.$viewFolder}/relation-list`),
195
198
  source: this.$configuration.source(),
196
199
  directory: this.directory('/resources/views/generathor'),
197
200
  prepareItems: (items) => new hasManyRelation_1.HasManyRelation(items, this.$configuration).transform(),
@@ -217,39 +220,95 @@ class LaravelGenerator {
217
220
  templates[this.templateKey('pk-trait')] = new generathor_1.GeneratorForCollection({
218
221
  template: this.templateFile('others/pk-trait'),
219
222
  source: this.$configuration.source(),
223
+ overwriteFiles: false,
220
224
  prepareItems: () => [],
221
225
  file: this.directory('/app/Models/Generathor/GenerathorKey.php'),
222
226
  });
227
+ const laravelUserFile = this.directory('/app/Models/LaravelUser.php');
228
+ if (this.$configuration.createLaravel12UserModel()) {
229
+ templates[this.templateKey('l12-user-model')] =
230
+ new generathor_1.GeneratorForCollection({
231
+ template: this.templateFile('eloquent/laravel12/user'),
232
+ source: this.$configuration.source(),
233
+ overwriteFiles: false,
234
+ prepareItems: () => [],
235
+ file: laravelUserFile,
236
+ });
237
+ }
238
+ if (this.$configuration.createLaravel11UserModel()) {
239
+ templates[this.templateKey('l11-user-model')] =
240
+ new generathor_1.GeneratorForCollection({
241
+ template: this.templateFile('eloquent/laravel11/user'),
242
+ source: this.$configuration.source(),
243
+ overwriteFiles: false,
244
+ prepareItems: () => [],
245
+ file: laravelUserFile,
246
+ });
247
+ }
248
+ if (!(0, fs_1.existsSync)(laravelUserFile) &&
249
+ (this.$configuration.createLaravel12UserModel() ||
250
+ this.$configuration.createLaravel11UserModel())) {
251
+ templates[this.templateKey('relation-item-view')] = new generathor_1.GeneratorForItem({
252
+ template: this.templateFile('eloquent/child'),
253
+ source: this.$configuration.source(),
254
+ directory: this.directory('/app/Models'),
255
+ prepareItems: (items) => items
256
+ .filter((item) => item.table == 'users')
257
+ .map((item) => item.laravel.eloquent),
258
+ fileName: () => 'User.php',
259
+ });
260
+ }
223
261
  if (this.$configuration.createEloquentModelsOnly()) {
224
262
  return templates;
225
263
  }
264
+ if (this.$configuration.laravelVersion() == 12) {
265
+ templates[this.templateKey('banner')] = new generathor_1.GeneratorForCollection({
266
+ template: this.templateFile('views/laravel12/banner'),
267
+ source: this.$configuration.source(),
268
+ overwriteFiles: false,
269
+ prepareItems: () => [],
270
+ file: this.directory('/resources/views/components/generathor/banner.blade.php'),
271
+ });
272
+ templates[this.templateKey('pagination')] = new generathor_1.GeneratorForCollection({
273
+ template: this.templateFile('others/laravel12/pagination'),
274
+ source: this.$configuration.source(),
275
+ overwriteFiles: false,
276
+ prepareItems: () => [],
277
+ file: this.directory('/resources/views/vendor/pagination/tailwind.blade.php'),
278
+ });
279
+ }
226
280
  templates[this.templateKey('record-input')] = new generathor_1.GeneratorForCollection({
227
- template: this.templateFile('views/record-input'),
281
+ template: this.templateFile(`views/${this.$viewFolder}/record-input`),
228
282
  source: this.$configuration.source(),
283
+ overwriteFiles: false,
229
284
  prepareItems: () => [],
230
285
  file: this.directory('/resources/views/components/generathor/record-input.blade.php'),
231
286
  });
232
287
  templates[this.templateKey('breadcrumbs')] = new generathor_1.GeneratorForCollection({
233
- template: this.templateFile('views/breadcrumbs'),
288
+ template: this.templateFile(`views/${this.$viewFolder}/breadcrumbs`),
234
289
  source: this.$configuration.source(),
290
+ overwriteFiles: false,
235
291
  prepareItems: () => [],
236
292
  file: this.directory('/resources/views/components/generathor/breadcrumbs.blade.php'),
237
293
  });
238
294
  templates[this.templateKey('tabs')] = new generathor_1.GeneratorForCollection({
239
- template: this.templateFile('views/tabs'),
295
+ template: this.templateFile(`views/${this.$viewFolder}/tabs`),
240
296
  source: this.$configuration.source(),
297
+ overwriteFiles: false,
241
298
  prepareItems: () => [],
242
299
  file: this.directory('/resources/views/components/generathor/tabs.blade.php'),
243
300
  });
244
301
  templates[this.templateKey('modal')] = new generathor_1.GeneratorForCollection({
245
- template: this.templateFile('views/modal'),
302
+ template: this.templateFile(`views/${this.$viewFolder}/modal`),
246
303
  source: this.$configuration.source(),
304
+ overwriteFiles: false,
247
305
  prepareItems: () => [],
248
306
  file: this.directory('/resources/views/components/generathor/modal.blade.php'),
249
307
  });
250
308
  templates[this.templateKey('loader')] = new generathor_1.GeneratorForCollection({
251
- template: this.templateFile('views/loader'),
309
+ template: this.templateFile(`views/${this.$viewFolder}/loader`),
252
310
  source: this.$configuration.source(),
311
+ overwriteFiles: false,
253
312
  prepareItems: () => [],
254
313
  file: this.directory('/resources/views/components/generathor/loader.blade.php'),
255
314
  });
@@ -274,6 +333,7 @@ class LaravelGenerator {
274
333
  templates[this.templateKey(`icon-${icon}`)] = new generathor_1.GeneratorForCollection({
275
334
  template: this.templateFile('views/icons/' + icon),
276
335
  source: this.$configuration.source(),
336
+ overwriteFiles: false,
277
337
  prepareItems: () => [],
278
338
  file: this.directory(`/resources/views/components/generathor/icon-${icon}.blade.php`),
279
339
  });
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- export * from './template';
1
+ export * from './generator';
2
2
  export * from './configuration';
3
+ export * from './laravel11';
4
+ export * from './laravel12';
package/dist/index.js CHANGED
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./template"), exports);
17
+ __exportStar(require("./generator"), exports);
18
18
  __exportStar(require("./configuration"), exports);
19
+ __exportStar(require("./laravel11"), exports);
20
+ __exportStar(require("./laravel12"), exports);
@@ -0,0 +1,7 @@
1
+ import { ConfigurationAttributes } from './configuration';
2
+ import { LaravelGenerator } from './generator';
3
+ export declare class Laravel11 {
4
+ static jetstreamEloquentModels(configuration?: ConfigurationAttributes): LaravelGenerator;
5
+ static eloquentModels(configuration?: ConfigurationAttributes): LaravelGenerator;
6
+ static jetstreamCrud(configuration?: ConfigurationAttributes): LaravelGenerator;
7
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Laravel11 = void 0;
4
+ const generator_1 = require("./generator");
5
+ class Laravel11 {
6
+ static jetstreamEloquentModels(configuration) {
7
+ configuration = configuration || {};
8
+ configuration.createEloquentModelsOnly = true;
9
+ configuration.createChildModel = true;
10
+ configuration.createLaravel11UserModel = true;
11
+ configuration.laravelVersion = 11;
12
+ configuration.eloquent = configuration.eloquent || {};
13
+ configuration.eloquent.customParents =
14
+ configuration.eloquent.customParents || {};
15
+ configuration.eloquent.customParents['users'] =
16
+ 'App\\Models\\LaravelUser as Model';
17
+ return new generator_1.LaravelGenerator(configuration);
18
+ }
19
+ static eloquentModels(configuration) {
20
+ configuration = configuration || {};
21
+ configuration.createEloquentModelsOnly = true;
22
+ configuration.createChildModel = true;
23
+ return new generator_1.LaravelGenerator(configuration);
24
+ }
25
+ static jetstreamCrud(configuration) {
26
+ var _a;
27
+ configuration = configuration || {};
28
+ configuration.createEloquentModelsOnly = false;
29
+ configuration.createChildModel = true;
30
+ configuration.createLaravel11UserModel = true;
31
+ configuration.laravelVersion = 11;
32
+ configuration.eloquent = configuration.eloquent || {};
33
+ configuration.eloquent.customParents =
34
+ configuration.eloquent.customParents || {};
35
+ configuration.eloquent.customParents['users'] =
36
+ 'App\\Models\\LaravelUser as Model';
37
+ configuration.layout = (_a = configuration.layout) !== null && _a !== void 0 ? _a : 'app-layout';
38
+ return new generator_1.LaravelGenerator(configuration);
39
+ }
40
+ }
41
+ exports.Laravel11 = Laravel11;
@@ -0,0 +1,7 @@
1
+ import { ConfigurationAttributes } from './configuration';
2
+ import { LaravelGenerator } from './generator';
3
+ export declare class Laravel12 {
4
+ static starterKitEloquentModels(configuration?: ConfigurationAttributes): LaravelGenerator;
5
+ static eloquentModels(configuration?: ConfigurationAttributes): LaravelGenerator;
6
+ static starterKitCrud(configuration?: ConfigurationAttributes): LaravelGenerator;
7
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Laravel12 = void 0;
4
+ const generator_1 = require("./generator");
5
+ const laravel11_1 = require("./laravel11");
6
+ class Laravel12 {
7
+ static starterKitEloquentModels(configuration) {
8
+ configuration = configuration || {};
9
+ configuration.createEloquentModelsOnly = true;
10
+ configuration.createChildModel = true;
11
+ configuration.createLaravel12UserModel = true;
12
+ configuration.laravelVersion = 12;
13
+ configuration.eloquent = configuration.eloquent || {};
14
+ configuration.eloquent.customParents =
15
+ configuration.eloquent.customParents || {};
16
+ configuration.eloquent.customParents['users'] =
17
+ 'App\\Models\\LaravelUser as Model';
18
+ return new generator_1.LaravelGenerator(configuration);
19
+ }
20
+ static eloquentModels(configuration) {
21
+ return laravel11_1.Laravel11.eloquentModels(configuration);
22
+ }
23
+ static starterKitCrud(configuration) {
24
+ var _a;
25
+ configuration = configuration || {};
26
+ configuration.createEloquentModelsOnly = false;
27
+ configuration.createChildModel = true;
28
+ configuration.createLaravel12UserModel = true;
29
+ configuration.laravelVersion = 12;
30
+ configuration.eloquent = configuration.eloquent || {};
31
+ configuration.eloquent.customParents =
32
+ configuration.eloquent.customParents || {};
33
+ configuration.eloquent.customParents['users'] =
34
+ 'App\\Models\\LaravelUser as Model';
35
+ configuration.layout = (_a = configuration.layout) !== null && _a !== void 0 ? _a : 'layouts.app';
36
+ return new generator_1.LaravelGenerator(configuration);
37
+ }
38
+ }
39
+ exports.Laravel12 = Laravel12;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generathor-laravel",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Use this to create Eloquent models and CRUDs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "generathor-db": "^1.0.2",
41
- "generathor": "^1.0.11"
41
+ "generathor": "^1.0.12"
42
42
  },
43
43
  "optionalDependencies": {
44
44
  "mysql2": "^3.11.3"
@@ -0,0 +1,67 @@
1
+ <?php
2
+
3
+ namespace App\Models;
4
+
5
+ // use Illuminate\Contracts\Auth\MustVerifyEmail;
6
+ use Illuminate\Database\Eloquent\Factories\HasFactory;
7
+ use Illuminate\Foundation\Auth\User as Authenticatable;
8
+ use Illuminate\Notifications\Notifiable;
9
+ use Laravel\Fortify\TwoFactorAuthenticatable;
10
+ use Laravel\Jetstream\HasProfilePhoto;
11
+ use Laravel\Sanctum\HasApiTokens;
12
+
13
+ class LaravelUser extends Authenticatable
14
+ {
15
+ use HasApiTokens;
16
+
17
+ /** @use HasFactory<\Database\Factories\UserFactory> */
18
+ use HasFactory;
19
+ use HasProfilePhoto;
20
+ use Notifiable;
21
+ use TwoFactorAuthenticatable;
22
+
23
+ /**
24
+ * The attributes that are mass assignable.
25
+ *
26
+ * @var array<int, string>
27
+ */
28
+ protected $fillable = [
29
+ 'name',
30
+ 'email',
31
+ 'password',
32
+ ];
33
+
34
+ /**
35
+ * The attributes that should be hidden for serialization.
36
+ *
37
+ * @var array<int, string>
38
+ */
39
+ protected $hidden = [
40
+ 'password',
41
+ 'remember_token',
42
+ 'two_factor_recovery_codes',
43
+ 'two_factor_secret',
44
+ ];
45
+
46
+ /**
47
+ * The accessors to append to the model's array form.
48
+ *
49
+ * @var array<int, string>
50
+ */
51
+ protected $appends = [
52
+ 'profile_photo_url',
53
+ ];
54
+
55
+ /**
56
+ * Get the attributes that should be cast.
57
+ *
58
+ * @return array<string, string>
59
+ */
60
+ protected function casts(): array
61
+ {
62
+ return [
63
+ 'email_verified_at' => 'datetime',
64
+ 'password' => 'hashed',
65
+ ];
66
+ }
67
+ }