generathor-laravel 1.0.4 → 2.0.0
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.
- package/README.md +62 -359
- package/dist/index.d.ts +37 -4
- package/dist/index.js +831 -19
- package/package.json +74 -44
- package/templates/eloquent/child.ejs +15 -0
- package/templates/eloquent/filter.ejs +69 -0
- package/templates/eloquent/parent.ejs +202 -0
- package/templates/{others/pk-trait.handlebars → eloquent/pk-trait.ejs} +1 -1
- package/templates/eloquent/{laravel12/user.handlebars → user-13.ejs} +11 -25
- package/templates/livewire/attach-form.ejs +52 -0
- package/templates/livewire/components/disclosure-content.ejs +9 -0
- package/templates/livewire/components/disclosure-trigger.ejs +7 -0
- package/templates/livewire/components/edit.ejs +51 -0
- package/templates/livewire/components/list.ejs +81 -0
- package/templates/livewire/components/record-select.ejs +121 -0
- package/templates/livewire/components/related-list.ejs +99 -0
- package/templates/livewire/components/related-view.ejs +102 -0
- package/templates/livewire/components/view.ejs +30 -0
- package/templates/livewire/components/with-error-handler.ejs +20 -0
- package/templates/livewire/components/with-filterable-list.ejs +42 -0
- package/templates/livewire/components/with-messages.ejs +25 -0
- package/templates/livewire/form.ejs +51 -0
- package/templates/livewire/partials/form.ejs +27 -0
- package/templates/livewire/routes.ejs +53 -0
- package/templates/livewire/view-edit.ejs +59 -0
- package/templates/livewire/view-item.ejs +168 -0
- package/templates/livewire/view-list.ejs +217 -0
- package/templates/livewire/view-menu.ejs +23 -0
- package/templates/livewire/view-relation-belongs-to.ejs +277 -0
- package/templates/livewire/view-relation-has-many.ejs +252 -0
- package/dist/configuration.d.ts +0 -31
- package/dist/configuration.js +0 -52
- package/dist/generator.d.ts +0 -21
- package/dist/generator.js +0 -344
- package/dist/helpers/handlebars.d.ts +0 -3
- package/dist/helpers/handlebars.js +0 -20
- package/dist/helpers/naming.d.ts +0 -18
- package/dist/helpers/naming.js +0 -98
- package/dist/helpers/string.d.ts +0 -27
- package/dist/helpers/string.js +0 -120
- package/dist/helpers/type.d.ts +0 -4
- package/dist/helpers/type.js +0 -41
- package/dist/laravel11.d.ts +0 -7
- package/dist/laravel11.js +0 -41
- package/dist/laravel12.d.ts +0 -7
- package/dist/laravel12.js +0 -39
- package/dist/transformers/collection/attachForm.d.ts +0 -4
- package/dist/transformers/collection/attachForm.js +0 -55
- package/dist/transformers/collection/attachRequest.d.ts +0 -5
- package/dist/transformers/collection/attachRequest.js +0 -92
- package/dist/transformers/collection/base.d.ts +0 -20
- package/dist/transformers/collection/base.js +0 -54
- package/dist/transformers/collection/baseController.d.ts +0 -4
- package/dist/transformers/collection/baseController.js +0 -14
- package/dist/transformers/collection/belongsToRelation.d.ts +0 -5
- package/dist/transformers/collection/belongsToRelation.js +0 -86
- package/dist/transformers/collection/controller.d.ts +0 -8
- package/dist/transformers/collection/controller.js +0 -163
- package/dist/transformers/collection/createRelationForm.d.ts +0 -4
- package/dist/transformers/collection/createRelationForm.js +0 -163
- package/dist/transformers/collection/filterRelationForm.d.ts +0 -4
- package/dist/transformers/collection/filterRelationForm.js +0 -164
- package/dist/transformers/collection/hasManyRelation.d.ts +0 -5
- package/dist/transformers/collection/hasManyRelation.js +0 -91
- package/dist/transformers/collection/menu.d.ts +0 -4
- package/dist/transformers/collection/menu.js +0 -25
- package/dist/transformers/collection/route.d.ts +0 -5
- package/dist/transformers/collection/route.js +0 -123
- package/dist/transformers/item/base.d.ts +0 -19
- package/dist/transformers/item/base.js +0 -33
- package/dist/transformers/item/edit.d.ts +0 -4
- package/dist/transformers/item/edit.js +0 -21
- package/dist/transformers/item/eloquent.d.ts +0 -4
- package/dist/transformers/item/eloquent.js +0 -158
- package/dist/transformers/item/filter.d.ts +0 -5
- package/dist/transformers/item/filter.js +0 -41
- package/dist/transformers/item/forms.d.ts +0 -4
- package/dist/transformers/item/forms.js +0 -226
- package/dist/transformers/item/laravel.d.ts +0 -15
- package/dist/transformers/item/laravel.js +0 -36
- package/dist/transformers/item/list.d.ts +0 -4
- package/dist/transformers/item/list.js +0 -36
- package/dist/transformers/item/requests.d.ts +0 -4
- package/dist/transformers/item/requests.js +0 -125
- package/dist/transformers/item/show.d.ts +0 -5
- package/dist/transformers/item/show.js +0 -54
- package/templates/eloquent/child.handlebars +0 -13
- package/templates/eloquent/filter.handlebars +0 -88
- package/templates/eloquent/laravel11/user.handlebars +0 -67
- package/templates/eloquent/parent.handlebars +0 -64
- package/templates/others/controller.handlebars +0 -185
- package/templates/others/laravel11/base-controller.handlebars +0 -46
- package/templates/others/laravel12/base-controller.handlebars +0 -54
- package/templates/others/laravel12/pagination.handlebars +0 -106
- package/templates/others/request.handlebars +0 -32
- package/templates/others/routes.handlebars +0 -16
- package/templates/views/icons/check-circle.handlebars +0 -3
- package/templates/views/icons/chevron-down.handlebars +0 -3
- package/templates/views/icons/chevron-right.handlebars +0 -3
- package/templates/views/icons/computer.handlebars +0 -3
- package/templates/views/icons/eye.handlebars +0 -4
- package/templates/views/icons/funnel.handlebars +0 -3
- package/templates/views/icons/home.handlebars +0 -3
- package/templates/views/icons/link.handlebars +0 -3
- package/templates/views/icons/list-bullet.handlebars +0 -3
- package/templates/views/icons/pencil.handlebars +0 -3
- package/templates/views/icons/plus.handlebars +0 -3
- package/templates/views/icons/trash.handlebars +0 -3
- package/templates/views/icons/unlink.handlebars +0 -3
- package/templates/views/icons/x-circle.handlebars +0 -3
- package/templates/views/icons/x.handlebars +0 -3
- package/templates/views/laravel11/breadcrumbs.handlebars +0 -21
- package/templates/views/laravel11/edit.handlebars +0 -41
- package/templates/views/laravel11/form.handlebars +0 -103
- package/templates/views/laravel11/index.handlebars +0 -181
- package/templates/views/laravel11/loader.handlebars +0 -6
- package/templates/views/laravel11/menu.handlebars +0 -31
- package/templates/views/laravel11/modal.handlebars +0 -36
- package/templates/views/laravel11/record-input.handlebars +0 -90
- package/templates/views/laravel11/relation-item.handlebars +0 -180
- package/templates/views/laravel11/relation-list.handlebars +0 -199
- package/templates/views/laravel11/show.handlebars +0 -134
- package/templates/views/laravel11/tabs.handlebars +0 -16
- package/templates/views/laravel12/banner.handlebars +0 -48
- package/templates/views/laravel12/breadcrumbs.handlebars +0 -21
- package/templates/views/laravel12/edit.handlebars +0 -31
- package/templates/views/laravel12/form.handlebars +0 -103
- package/templates/views/laravel12/index.handlebars +0 -171
- package/templates/views/laravel12/loader.handlebars +0 -6
- package/templates/views/laravel12/menu.handlebars +0 -21
- package/templates/views/laravel12/modal.handlebars +0 -36
- package/templates/views/laravel12/record-input.handlebars +0 -90
- package/templates/views/laravel12/relation-item.handlebars +0 -170
- package/templates/views/laravel12/relation-list.handlebars +0 -189
- package/templates/views/laravel12/show.handlebars +0 -124
- package/templates/views/laravel12/tabs.handlebars +0 -16
package/README.md
CHANGED
|
@@ -19,38 +19,33 @@
|
|
|
19
19
|
|
|
20
20
|
# Generathor Laravel
|
|
21
21
|
|
|
22
|
-
**Generathor Laravel** allows you to automatically generate Eloquent models and
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Table of Contents
|
|
27
|
-
|
|
28
|
-
1. [Installation](#installation)
|
|
29
|
-
2. [Generating Files](#generating-files)
|
|
30
|
-
1. [Generating Eloquent Models](#generating-eloquent-models)
|
|
31
|
-
2. [Generating Eloquent Models and CRUDs](#generating-eloquent-models-and-cruds)
|
|
32
|
-
3. [Additional Settings](#additional-settings)
|
|
33
|
-
4. [Files](#files)
|
|
34
|
-
5. [TODO](#todo)
|
|
22
|
+
**Generathor Laravel** allows you to automatically generate Eloquent models and Livewire CRUDs (using Flux UI) based on your database structure.
|
|
35
23
|
|
|
36
24
|
---
|
|
37
25
|
|
|
38
26
|
## Installation
|
|
39
27
|
|
|
40
|
-
|
|
28
|
+
Install the core dependencies:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
$ npm i -D generathor generathor-db generathor-laravel
|
|
32
|
+
```
|
|
41
33
|
|
|
34
|
+
Depending on your database, install the driver you need:
|
|
42
35
|
```bash
|
|
43
|
-
|
|
36
|
+
# For MySQL
|
|
37
|
+
$ npm i -D mysql2
|
|
38
|
+
|
|
39
|
+
# For PostgreSQL
|
|
40
|
+
$ npm i -D pg
|
|
44
41
|
```
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
Create the configuration file:
|
|
47
44
|
|
|
48
45
|
```bash
|
|
49
46
|
$ touch generathor.config.cjs
|
|
50
47
|
```
|
|
51
48
|
|
|
52
|
-
> The content of the configuration file will depend on what you want to generate.
|
|
53
|
-
|
|
54
49
|
Add the following script to your `package.json`:
|
|
55
50
|
|
|
56
51
|
```json
|
|
@@ -61,184 +56,90 @@ Add the following script to your `package.json`:
|
|
|
61
56
|
|
|
62
57
|
---
|
|
63
58
|
|
|
64
|
-
##
|
|
65
|
-
|
|
66
|
-
Whether you need to generate Eloquent models or CRUDs, you must install the PHP dependencies by running the following command:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
$ composer require tucker-eric/eloquentfilter kyslik/column-sortable
|
|
70
|
-
```
|
|
59
|
+
## Configuration
|
|
71
60
|
|
|
72
|
-
|
|
61
|
+
In your `generathor.config.cjs`, set up the connection to your database and specify the generator configuration.
|
|
73
62
|
|
|
74
|
-
|
|
63
|
+
You can choose to generate only **Eloquent** models, or **Livewire** components with their corresponding views.
|
|
75
64
|
|
|
76
|
-
### Generating
|
|
65
|
+
### Generating Livewire CRUDs
|
|
77
66
|
|
|
78
|
-
|
|
67
|
+
This will generate Eloquent models, Livewire components, and views for the CRUD interface.
|
|
79
68
|
|
|
80
|
-
```
|
|
69
|
+
```javascript
|
|
81
70
|
const { Source } = require('generathor-db');
|
|
82
|
-
const {
|
|
71
|
+
const { livewire } = require('generathor-laravel');
|
|
83
72
|
|
|
84
|
-
const laravel = new LaravelGenerator({
|
|
85
|
-
createEloquentModelsOnly: true
|
|
86
|
-
});
|
|
87
73
|
const dbSource = new Source({
|
|
88
|
-
type: 'mysql',
|
|
74
|
+
type: 'mysql', // or 'postgres'
|
|
89
75
|
configuration: {
|
|
90
76
|
host: 'localhost',
|
|
91
|
-
port:
|
|
92
|
-
user: '
|
|
93
|
-
password: '
|
|
77
|
+
port: 3306,
|
|
78
|
+
user: 'root',
|
|
79
|
+
password: 'password',
|
|
94
80
|
database: 'my_database'
|
|
95
81
|
},
|
|
96
82
|
excludes: ['migrations']
|
|
97
|
-
}
|
|
98
|
-
laravel.transformer.bind(laravel)
|
|
99
|
-
]);
|
|
83
|
+
});
|
|
100
84
|
|
|
101
85
|
module.exports = {
|
|
102
86
|
sources: {
|
|
103
87
|
db: dbSource,
|
|
104
88
|
},
|
|
105
|
-
generators:
|
|
89
|
+
generators: livewire()
|
|
106
90
|
};
|
|
107
91
|
```
|
|
108
92
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
$ npm run generathor
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
### Generating Eloquent Models and CRUDs
|
|
93
|
+
### Generating Eloquent Models Only
|
|
118
94
|
|
|
119
|
-
|
|
95
|
+
If you only need the models without the CRUD UI:
|
|
120
96
|
|
|
121
|
-
```
|
|
97
|
+
```javascript
|
|
122
98
|
const { Source } = require('generathor-db');
|
|
123
|
-
const {
|
|
99
|
+
const { eloquent } = require('generathor-laravel');
|
|
124
100
|
|
|
125
|
-
const laravel = new LaravelGenerator();
|
|
126
101
|
const dbSource = new Source({
|
|
127
|
-
type: 'mysql',
|
|
102
|
+
type: 'mysql', // or 'postgres'
|
|
128
103
|
configuration: {
|
|
129
104
|
host: 'localhost',
|
|
130
|
-
port:
|
|
131
|
-
user: '
|
|
132
|
-
password: '
|
|
105
|
+
port: 3306,
|
|
106
|
+
user: 'root',
|
|
107
|
+
password: 'password',
|
|
133
108
|
database: 'my_database'
|
|
134
109
|
},
|
|
135
110
|
excludes: ['migrations']
|
|
136
|
-
}
|
|
137
|
-
laravel.transformer.bind(laravel)
|
|
138
|
-
]);
|
|
111
|
+
});
|
|
139
112
|
|
|
140
113
|
module.exports = {
|
|
141
114
|
sources: {
|
|
142
115
|
db: dbSource,
|
|
143
116
|
},
|
|
144
|
-
generators:
|
|
117
|
+
generators: eloquent()
|
|
145
118
|
};
|
|
146
119
|
```
|
|
147
120
|
|
|
148
|
-
|
|
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');
|
|
121
|
+
---
|
|
182
122
|
|
|
183
|
-
|
|
184
|
-
```
|
|
123
|
+
## Generating Files
|
|
185
124
|
|
|
186
|
-
|
|
125
|
+
Once configured, execute the script to generate your files:
|
|
187
126
|
|
|
188
127
|
```bash
|
|
189
128
|
$ npm run generathor
|
|
190
129
|
```
|
|
191
130
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
#### Installing frontend dependencies
|
|
131
|
+
**Requirements:**
|
|
132
|
+
The generated UI components use [Flux UI](https://fluxui.dev/) primitives and [Livewire](https://livewire.laravel.com/). Make sure they are installed and configured in your Laravel application before using the generated views.
|
|
195
133
|
|
|
196
|
-
You
|
|
197
|
-
[https://tailwindcss.com/docs/guides/laravel](https://tailwindcss.com/docs/guides/laravel)
|
|
198
|
-
|
|
199
|
-
Also, you need to install the following packages:
|
|
200
|
-
|
|
201
|
-
* alpinejs
|
|
202
|
-
* @alpinejs/collapse
|
|
203
|
-
* @alpinejs/mask
|
|
204
|
-
* laravel-precognition-alpine
|
|
205
|
-
* sweetalert2
|
|
206
|
-
* @fortawesome/fontawesome-free
|
|
207
|
-
* axios
|
|
134
|
+
You must also install the required PHP dependencies in your Laravel project:
|
|
208
135
|
|
|
209
136
|
```bash
|
|
210
|
-
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
File `app.js` must contain:
|
|
214
|
-
|
|
215
|
-
```js
|
|
216
|
-
import Alpine from 'alpinejs';
|
|
217
|
-
import collapse from '@alpinejs/collapse';
|
|
218
|
-
import mask from '@alpinejs/mask';
|
|
219
|
-
import Precognition from 'laravel-precognition-alpine';
|
|
220
|
-
import Swal from 'sweetalert2';
|
|
221
|
-
import axios from 'axios';// Laravel 11 import this by default in bootstrap.js
|
|
222
|
-
|
|
223
|
-
window.axios = axios;
|
|
224
|
-
window.Alpine = Alpine;
|
|
225
|
-
window.Swal = Swal;
|
|
226
|
-
|
|
227
|
-
Alpine.plugin(Precognition);
|
|
228
|
-
Alpine.plugin(collapse);
|
|
229
|
-
Alpine.plugin(mask);
|
|
230
|
-
Alpine.start();
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
File `app.css` must contain:
|
|
234
|
-
|
|
235
|
-
```css
|
|
236
|
-
@import "@fortawesome/fontawesome-free/css/all.css";
|
|
137
|
+
$ composer require tucker-eric/eloquentfilter kyslik/column-sortable
|
|
237
138
|
```
|
|
238
139
|
|
|
239
|
-
|
|
140
|
+
### Expose the routes
|
|
240
141
|
|
|
241
|
-
Add
|
|
142
|
+
Add generathor routes to `routes/web.php`:
|
|
242
143
|
|
|
243
144
|
```php
|
|
244
145
|
Route::prefix('manage')->group(function () {
|
|
@@ -246,9 +147,9 @@ Route::prefix('manage')->group(function () {
|
|
|
246
147
|
});
|
|
247
148
|
```
|
|
248
149
|
|
|
249
|
-
|
|
150
|
+
### Set up your 'home' route
|
|
250
151
|
|
|
251
|
-
You need to set up your
|
|
152
|
+
You need to set up your home route. You can change the home route reference in the `generathor.config.cjs` file.
|
|
252
153
|
|
|
253
154
|
```php
|
|
254
155
|
Route::get('/', function () {
|
|
@@ -256,218 +157,20 @@ Route::get('/', function () {
|
|
|
256
157
|
})->name('home');
|
|
257
158
|
```
|
|
258
159
|
|
|
259
|
-
#### Set up datepickers (optional)
|
|
260
|
-
|
|
261
|
-
Install the following package:
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
npm i -D flatpickr
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
Add the following code to `app.js`:
|
|
268
|
-
|
|
269
|
-
```js
|
|
270
|
-
import flatpickr from 'flatpickr';
|
|
271
|
-
|
|
272
|
-
flatpickr('.input-datetime', {
|
|
273
|
-
enableTime: true,
|
|
274
|
-
enableSeconds: true,
|
|
275
|
-
dateFormat: 'Y-m-d H:i:S',
|
|
276
|
-
});
|
|
277
|
-
flatpickr('.input-date', {
|
|
278
|
-
dateFormat: 'Y-m-d',
|
|
279
|
-
});
|
|
280
|
-
flatpickr('.input-time', {
|
|
281
|
-
noCalendar: true,
|
|
282
|
-
enableTime: true,
|
|
283
|
-
enableSeconds: true,
|
|
284
|
-
dateFormat: 'H:i:S',
|
|
285
|
-
});
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Add the following code to `app.css`:
|
|
289
|
-
|
|
290
|
-
```css
|
|
291
|
-
@import "flatpickr/dist/flatpickr.css";
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
#### Set up loading spinner (optional)
|
|
295
|
-
|
|
296
|
-
Add the following code to `app.js`:
|
|
297
|
-
|
|
298
|
-
```js
|
|
299
|
-
const loader = document.getElementById('generathor-loader');
|
|
300
|
-
window.showLoading = () => {
|
|
301
|
-
if (loader) {
|
|
302
|
-
loader.classList.remove('hidden');
|
|
303
|
-
loader.classList.add('flex');
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
window.hideLoading = () => {
|
|
307
|
-
if (loader) {
|
|
308
|
-
loader.classList.remove('flex');
|
|
309
|
-
loader.classList.add('hidden');
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
const forms = document.getElementsByTagName('form');
|
|
314
|
-
for (const form of forms) {
|
|
315
|
-
form.addEventListener('submit', window.showLoading);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Only for Livewire
|
|
319
|
-
if (typeof Livewire !== undefined) {
|
|
320
|
-
Livewire.hook('commit', ({ succeed, fail }) => {
|
|
321
|
-
succeed(() => {
|
|
322
|
-
window.hideLoading();
|
|
323
|
-
});
|
|
324
|
-
fail(() => {
|
|
325
|
-
window.hideLoading();
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
Add the following code in `layout.blade.php` or in your layout:
|
|
332
|
-
|
|
333
|
-
```blade
|
|
334
|
-
<!-- LARAVEL 11 -->
|
|
335
|
-
<x-generathor.loader />
|
|
336
|
-
<x-banner /><!-- You can use this with laravel 11 + jetstream -->
|
|
337
|
-
|
|
338
|
-
<!-- LARAVEL 12 -->
|
|
339
|
-
<x-generathor.loader />
|
|
340
|
-
<x-generathor.banner /><!-- Only needed with laravel 12 -->
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
#### Set up header (optional)
|
|
344
|
-
|
|
345
|
-
You can define a header in your layout. For example, in `layout.blade.php` or in your layout:
|
|
346
|
-
|
|
347
|
-
```blade
|
|
348
|
-
@if(isset($header))
|
|
349
|
-
<div>
|
|
350
|
-
{{$header}}
|
|
351
|
-
</div>
|
|
352
|
-
@endif
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
## Additional settings
|
|
358
|
-
|
|
359
|
-
You can modify settings in the `generathor.config.cjs` file.
|
|
360
|
-
|
|
361
|
-
| Variable | Required | Type | Default | Description |
|
|
362
|
-
|----------------------------|----------|------------------------|--------------------------------------|-------------------------------------------------------------------------------------|
|
|
363
|
-
| `createChildModel` | `No` | boolean | true | Prevents overwriting the child class of a model, so you retain your custom changes. |
|
|
364
|
-
| `createEloquentModelsOnly` | `No` | boolean | false | Creates only Eloquent models, skipping the generation of other files. |
|
|
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. |
|
|
369
|
-
| `source` | `No` | string | 'db' | Reference to the Generathor source for database structure. |
|
|
370
|
-
| `directory` | `No` | string | '.' | Directory path for the Laravel project. |
|
|
371
|
-
| `homeRoute` | `No` | string | 'home' | Initial base route, used for redirection to the home page. |
|
|
372
|
-
| `layout` | `No` | string | 'layout' | Main layout of your project. |
|
|
373
|
-
| `eloquent` | `No` | object | | Object for defining parent classes for models. |
|
|
374
|
-
| `eloquent.parent` | `No` | string | 'Illuminate\Database\Eloquent\Model' | General parent class for models. |
|
|
375
|
-
| `eloquent.customParents` | `No` | Record<string, string> | {} | Parent class by table, allowing custom parent classes for specific tables. |
|
|
376
|
-
|
|
377
|
-
Example
|
|
378
|
-
|
|
379
|
-
```js
|
|
380
|
-
const { Source } = require('generathor-db');
|
|
381
|
-
const { LaravelGenerator }= require('generathor-laravel-testing');
|
|
382
|
-
|
|
383
|
-
const laravel = new LaravelGenerator({
|
|
384
|
-
ccreateChildModel: true,
|
|
385
|
-
createEloquentModelsOnly: false,
|
|
386
|
-
reference: 'laravel',
|
|
387
|
-
source: 'db2',
|
|
388
|
-
directory: './project',
|
|
389
|
-
homeRoute: 'index',
|
|
390
|
-
layout: 'app',
|
|
391
|
-
eloquent: {
|
|
392
|
-
parent: 'App\\Models\\Model',
|
|
393
|
-
customParents: {
|
|
394
|
-
users: 'App\\Models\\Jetstream\\User as Model',
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
const dbSource = new Source({
|
|
399
|
-
type: 'mysql',
|
|
400
|
-
configuration: {
|
|
401
|
-
host: 'localhost',
|
|
402
|
-
port: '3306',
|
|
403
|
-
user: 'my_user',
|
|
404
|
-
password: 'my_password',
|
|
405
|
-
database: 'my_database'
|
|
406
|
-
},
|
|
407
|
-
excludes: ['migrations']
|
|
408
|
-
}, [
|
|
409
|
-
laravel.transformer.bind(laravel)
|
|
410
|
-
]);
|
|
411
|
-
|
|
412
|
-
module.exports = {
|
|
413
|
-
sources: {
|
|
414
|
-
db: dbSource,
|
|
415
|
-
},
|
|
416
|
-
generators: laravel.generators()
|
|
417
|
-
};
|
|
418
|
-
```
|
|
419
|
-
|
|
420
160
|
---
|
|
421
161
|
|
|
422
|
-
##
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
* `resources/views/generathor/[table-context]/show.blade.php` (for each table)
|
|
438
|
-
* `resources/views/generathor/[table-context]/[relation].blade.php` (for each relationship in each table)
|
|
439
|
-
* `resources/views/components/generathor/[table-context]/create-form.blade.php` (for each table)
|
|
440
|
-
* `resources/views/components/generathor/[table-context]/filter-form.blade.php` (for each table)
|
|
441
|
-
* `resources/views/components/generathor/[table-context]/update-form.blade.php` (for each table)
|
|
442
|
-
* `resources/views/components/generathor/[table-context]/[attach-form].blade.php` (for each 'has-many' relationship in each table)
|
|
443
|
-
* `resources/views/components/generathor/[table-context]/[create-form].blade.php` (for each relationship in each table)
|
|
444
|
-
* `resources/views/components/generathor/[table-context]/[filter-form].blade.php` (for each 'has-many' relationship in each table)
|
|
445
|
-
* `app/Models/Generathor/GenerathorKey.php`
|
|
446
|
-
* `resources/views/components/generathor/record-input.blade.php`
|
|
447
|
-
* `resources/views/components/generathor/breadcrumbs.blade.php`
|
|
448
|
-
* `resources/views/components/generathor/tabs.blade.php`
|
|
449
|
-
* `resources/views/components/generathor/modal.blade.php`
|
|
450
|
-
* `resources/views/components/generathor/loader.blade.php`
|
|
451
|
-
* `resources/views/components/generathor/icon-check-circle.blade.php`
|
|
452
|
-
* `resources/views/components/generathor/icon-chevron-right.blade.php`
|
|
453
|
-
* `resources/views/components/generathor/icon-computer.blade.php`
|
|
454
|
-
* `resources/views/components/generathor/icon-eye.blade.php`
|
|
455
|
-
* `resources/views/components/generathor/icon-funnel.blade.php`
|
|
456
|
-
* `resources/views/components/generathor/icon-home.blade.php`
|
|
457
|
-
* `resources/views/components/generathor/icon-pencil.blade.php`
|
|
458
|
-
* `resources/views/components/generathor/icon-plus.blade.php`
|
|
459
|
-
* `resources/views/components/generathor/icon-trash.blade.php`
|
|
460
|
-
* `resources/views/components/generathor/icon-x-circle.blade.php`
|
|
461
|
-
* `resources/views/components/generathor/icon-x.blade.php`
|
|
462
|
-
* `resources/views/components/generathor/icon-chevron-down.blade.php`
|
|
463
|
-
* `resources/views/components/generathor/icon-list-bullet.blade.php`
|
|
464
|
-
* `resources/views/components/generathor/icon-link.blade.php`
|
|
465
|
-
* `resources/views/components/generathor/icon-unlink.blade.php`
|
|
466
|
-
|
|
467
|
-
---
|
|
468
|
-
|
|
469
|
-
## TODO
|
|
470
|
-
|
|
471
|
-
- [ ] Separate inputs into components.
|
|
472
|
-
- [ ] Customize inputs based on prefix or specific logic.
|
|
473
|
-
- [ ] TBD
|
|
162
|
+
## Configuration Options
|
|
163
|
+
|
|
164
|
+
When calling `eloquent(options)` or `livewire(options)`, you can pass an object with the following optional settings:
|
|
165
|
+
|
|
166
|
+
| Variable | Type | Default | Description |
|
|
167
|
+
|----------------------------|------------------------|--------------------------------------|-------------------------------------------------------------------------------------|
|
|
168
|
+
| `directory` | string | '.' | Directory path for the Laravel project. |
|
|
169
|
+
| `reference` | string | 'laravel' | Reference name used in templates. |
|
|
170
|
+
| `laravelVersion` | 13 | 13 | Laravel application version. |
|
|
171
|
+
| `createLaravelUserModel` | boolean | false | Check if a custom Laravel user model is required. |
|
|
172
|
+
| `onlyEloquentModels` | boolean | true (eloquent) / false (livewire) | Creates only Eloquent models, skipping the generation of other files. |
|
|
173
|
+
| `source` | string | 'db' | Reference to the Generathor source for database structure. |
|
|
174
|
+
| `homeRoute` | string | 'home' | Initial base route, used for redirection. |
|
|
175
|
+
| `eloquent.parent` | string | 'Illuminate\Database\Eloquent\Model' | General parent class for models. |
|
|
176
|
+
| `eloquent.customParents` | Record<string, string> | {} | Custom parent class by table, e.g. `{ users: 'App\\Models\\User' }`. |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type ConfigurationAttributes = {
|
|
2
|
+
laravelVersion?: 13;
|
|
3
|
+
onlyEloquentModels?: boolean;
|
|
4
|
+
createLaravelUserModel?: boolean;
|
|
5
|
+
reference?: string;
|
|
6
|
+
source?: string;
|
|
7
|
+
directory?: string;
|
|
8
|
+
homeRoute?: string;
|
|
9
|
+
eloquent?: {
|
|
10
|
+
parent?: string;
|
|
11
|
+
customParents?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
declare class Configuration {
|
|
15
|
+
private readonly attributes;
|
|
16
|
+
constructor(attributes: ConfigurationAttributes);
|
|
17
|
+
directory(): string;
|
|
18
|
+
reference(): string;
|
|
19
|
+
laravelVersion(): number;
|
|
20
|
+
createLaravelUserModel(): boolean;
|
|
21
|
+
createOnlyEloquentModels(): boolean;
|
|
22
|
+
source(): string;
|
|
23
|
+
homeRoute(): string;
|
|
24
|
+
eloquentParent(table: string): string;
|
|
25
|
+
}
|
|
26
|
+
import { GeneratorForCollection, GeneratorForItem } from "generathor";
|
|
27
|
+
type GeneratorType = GeneratorForItem | GeneratorForCollection;
|
|
28
|
+
declare class LaravelGenerator {
|
|
29
|
+
private readonly configuration;
|
|
30
|
+
constructor(configuration?: ConfigurationAttributes);
|
|
31
|
+
generators(): Record<string, GeneratorType>;
|
|
32
|
+
private providers;
|
|
33
|
+
}
|
|
34
|
+
type Generators = Record<string, GeneratorType>;
|
|
35
|
+
declare function eloquent(configuration?: ConfigurationAttributes): Generators;
|
|
36
|
+
declare function livewire(configuration?: ConfigurationAttributes): Generators;
|
|
37
|
+
export { livewire, eloquent, LaravelGenerator, ConfigurationAttributes, Configuration };
|