7
7
8
8
Generate Laravel models from an existing database.
9
9
10
+ Major features:
11
+ - PHPStan level 9 compliant
12
+ - Laravel 11 style
13
+ - Polymorphic relationships
14
+
10
15
## Installation
11
16
12
17
You can install the package via composer:
@@ -26,68 +31,165 @@ This is the contents of the published config file:
26
31
``` php
27
32
return [
28
33
'clean_models_directory_before_generation' => true,
29
-
30
- /**
31
- * Add declare(strict_types=1); to the top of each generated model file
32
- */
34
+
35
+ /*
36
+ |--------------------------------------------------------------------------
37
+ | Strict types
38
+ |--------------------------------------------------------------------------
39
+ |
40
+ | Add declare(strict_types=1); to the top of each generated model file
41
+ |
42
+ */
33
43
'strict_types' => true,
34
-
35
- /**
36
- * Add $connection model property
37
- */
38
- 'connection' => true,
39
-
40
- /**
41
- * Add $table model property
42
- */
44
+
45
+ /*
46
+ |--------------------------------------------------------------------------
47
+ | Models $table property
48
+ |--------------------------------------------------------------------------
49
+ |
50
+ | Add $table model property
51
+ |
52
+ */
43
53
'table' => true,
44
-
45
- /**
46
- * Add $primaryKey model property
47
- */
54
+
55
+ /*
56
+ |--------------------------------------------------------------------------
57
+ | Models $connection property
58
+ |--------------------------------------------------------------------------
59
+ |
60
+ | Add $connection model property
61
+ |
62
+ */
63
+ 'connection' => true,
64
+
65
+ /*'phpdocs' => [
66
+ 'scopes' => true,
67
+ ],*/
68
+
69
+ /*
70
+ |--------------------------------------------------------------------------
71
+ | Models $primaryKey property
72
+ |--------------------------------------------------------------------------
73
+ |
74
+ | Add $primaryKey model property
75
+ |
76
+ */
48
77
'primary_key' => true,
49
78
50
- /**
51
- * Add $primaryKey field to fillable array
52
- */
79
+ /*
80
+ |--------------------------------------------------------------------------
81
+ | Primary Key in Fillable
82
+ |--------------------------------------------------------------------------
83
+ |
84
+ | Add primary key column field to fillable array
85
+ |
86
+ */
53
87
'primary_key_in_fillable' => true,
54
88
55
- 'parent' => Illuminate\Database\Eloquent\Model::class,
89
+ /*
90
+ |--------------------------------------------------------------------------
91
+ | Models path
92
+ |--------------------------------------------------------------------------
93
+ |
94
+ | Where the models will be created
95
+ |
96
+ */
97
+ 'path' => app_path('Models'),
98
+
99
+ /*
100
+ |--------------------------------------------------------------------------
101
+ | Namespace
102
+ |--------------------------------------------------------------------------
103
+ |
104
+ | The namespace of the generated models
105
+ |
106
+ */
56
107
'namespace' => 'App\Models',
57
108
58
- /**
59
- * [
60
- * 'table_name' => 'polymorphic_type',
61
- *
62
- * ex. for official laravel documentation
63
- * 'posts' => 'commentable',
64
- *
65
- * ]
66
- */
109
+ /*
110
+ |--------------------------------------------------------------------------
111
+ | Parent
112
+ |--------------------------------------------------------------------------
113
+ |
114
+ | The parent class of the generated models
115
+ |
116
+ */
117
+ 'parent' => Illuminate\Database\Eloquent\Model::class,
118
+
119
+ /*
120
+ |--------------------------------------------------------------------------
121
+ | Base files
122
+ |--------------------------------------------------------------------------
123
+ |
124
+ | If you want to generate a base file for each model, you can enable this.
125
+ | The base file will be created within 'Base' directory inside the models' directory.
126
+ | If you want your base files be abstract you can enable it.
127
+ |
128
+ */
129
+ 'base_files' => [
130
+ 'enabled' => false,
131
+ 'abstract' => true,
132
+ ],
133
+
134
+ /*
135
+ |--------------------------------------------------------------------------
136
+ | Polymorphic relationships
137
+ |--------------------------------------------------------------------------
138
+ |
139
+ | Define polymorphic relationships
140
+ |
141
+ | [
142
+ | 'table_name' => 'polymorphic_type',
143
+ |
144
+ | ex. for official laravel documentation
145
+ | 'posts' => 'commentable',
146
+ | ]
147
+ |
148
+ */
67
149
'morphs' => [
68
150
],
69
151
70
- /**
71
- * Interface(s) implemented by all models
72
- */
152
+ /*
153
+ |--------------------------------------------------------------------------
154
+ | Interfaces
155
+ |--------------------------------------------------------------------------
156
+ |
157
+ | Interface(s) implemented by all models
158
+ |
159
+ */
73
160
'interfaces' => [
74
161
],
75
162
76
- /**
77
- * Trait(s) used by all models
78
- */
163
+ /*
164
+ |--------------------------------------------------------------------------
165
+ | Traits
166
+ |--------------------------------------------------------------------------
167
+ |
168
+ | Trait(s) implemented by all models
169
+ |
170
+ */
79
171
'traits' => [
80
172
],
81
173
82
- /**
83
- * Enum(s) used in laravel casts function
84
- */
174
+ /*
175
+ |--------------------------------------------------------------------------
176
+ | Enums
177
+ |--------------------------------------------------------------------------
178
+ |
179
+ | Enum(s) implemented by all models
180
+ |
181
+ */
85
182
'enums_casting' => [
86
183
],
87
184
88
- /**
89
- * Excluded Tables
90
- */
185
+ /*
186
+ |--------------------------------------------------------------------------
187
+ | Excluded Tables
188
+ |--------------------------------------------------------------------------
189
+ |
190
+ | These models will not be generated
191
+ |
192
+ */
91
193
'except' => [
92
194
'migrations',
93
195
'failed_jobs',
0 commit comments