Skip to content

Commit 4036023

Browse files
committedJan 1, 2025·
feat: update README
1 parent dd59e7d commit 4036023

File tree

2 files changed

+265
-79
lines changed

2 files changed

+265
-79
lines changed
 

‎README.md

+144-42
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
Generate Laravel models from an existing database.
99

10+
Major features:
11+
- PHPStan level 9 compliant
12+
- Laravel 11 style
13+
- Polymorphic relationships
14+
1015
## Installation
1116

1217
You can install the package via composer:
@@ -26,68 +31,165 @@ This is the contents of the published config file:
2631
```php
2732
return [
2833
'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+
*/
3343
'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+
*/
4353
'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+
*/
4877
'primary_key' => true,
4978

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+
*/
5387
'primary_key_in_fillable' => true,
5488

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+
*/
56107
'namespace' => 'App\Models',
57108

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+
*/
67149
'morphs' => [
68150
],
69151

70-
/**
71-
* Interface(s) implemented by all models
72-
*/
152+
/*
153+
|--------------------------------------------------------------------------
154+
| Interfaces
155+
|--------------------------------------------------------------------------
156+
|
157+
| Interface(s) implemented by all models
158+
|
159+
*/
73160
'interfaces' => [
74161
],
75162

76-
/**
77-
* Trait(s) used by all models
78-
*/
163+
/*
164+
|--------------------------------------------------------------------------
165+
| Traits
166+
|--------------------------------------------------------------------------
167+
|
168+
| Trait(s) implemented by all models
169+
|
170+
*/
79171
'traits' => [
80172
],
81173

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+
*/
85182
'enums_casting' => [
86183
],
87184

88-
/**
89-
* Excluded Tables
90-
*/
185+
/*
186+
|--------------------------------------------------------------------------
187+
| Excluded Tables
188+
|--------------------------------------------------------------------------
189+
|
190+
| These models will not be generated
191+
|
192+
*/
91193
'except' => [
92194
'migrations',
93195
'failed_jobs',

‎config/models-generator.php

+121-37
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,164 @@
66
return [
77
'clean_models_directory_before_generation' => true,
88

9-
/**
10-
* Add declare(strict_types=1); to the top of each generated model file
11-
*/
9+
/*
10+
|--------------------------------------------------------------------------
11+
| Strict types
12+
|--------------------------------------------------------------------------
13+
|
14+
| Add declare(strict_types=1); to the top of each generated model file
15+
|
16+
*/
1217
'strict_types' => true,
1318

14-
/**
15-
* Add $table model property
16-
*/
19+
/*
20+
|--------------------------------------------------------------------------
21+
| Models $table property
22+
|--------------------------------------------------------------------------
23+
|
24+
| Add $table model property
25+
|
26+
*/
1727
'table' => true,
1828

19-
/**
20-
* Add $connection model property
21-
*/
29+
/*
30+
|--------------------------------------------------------------------------
31+
| Models $connection property
32+
|--------------------------------------------------------------------------
33+
|
34+
| Add $connection model property
35+
|
36+
*/
2237
'connection' => true,
2338

2439
/*'phpdocs' => [
2540
'scopes' => true,
2641
],*/
2742

28-
/**
29-
* Add $primaryKey model property
30-
*/
43+
/*
44+
|--------------------------------------------------------------------------
45+
| Models $primaryKey property
46+
|--------------------------------------------------------------------------
47+
|
48+
| Add $primaryKey model property
49+
|
50+
*/
3151
'primary_key' => true,
3252

33-
/**
34-
* Add $primaryKey field to fillable array
35-
*/
53+
/*
54+
|--------------------------------------------------------------------------
55+
| Primary Key in Fillable
56+
|--------------------------------------------------------------------------
57+
|
58+
| Add primary key column field to fillable array
59+
|
60+
*/
3661
'primary_key_in_fillable' => true,
3762

63+
/*
64+
|--------------------------------------------------------------------------
65+
| Models path
66+
|--------------------------------------------------------------------------
67+
|
68+
| Where the models will be created
69+
|
70+
*/
3871
'path' => app_path('Models'),
3972

73+
/*
74+
|--------------------------------------------------------------------------
75+
| Namespace
76+
|--------------------------------------------------------------------------
77+
|
78+
| The namespace of the generated models
79+
|
80+
*/
4081
'namespace' => 'App\Models',
4182

83+
/*
84+
|--------------------------------------------------------------------------
85+
| Parent
86+
|--------------------------------------------------------------------------
87+
|
88+
| The parent class of the generated models
89+
|
90+
*/
4291
'parent' => Illuminate\Database\Eloquent\Model::class,
4392

93+
/*
94+
|--------------------------------------------------------------------------
95+
| Base files
96+
|--------------------------------------------------------------------------
97+
|
98+
| If you want to generate a base file for each model, you can enable this.
99+
| The base file will be created within 'Base' directory inside the models' directory.
100+
| If you want your base files be abstract you can enable it.
101+
|
102+
*/
44103
'base_files' => [
45104
'enabled' => false,
46105
'abstract' => true,
47106
],
48107

49-
/**
50-
* Define polymorphic relationships
51-
*
52-
* [
53-
* 'table_name' => 'polymorphic_type',
54-
*
55-
* ex. for official laravel documentation
56-
* 'posts' => 'commentable',
57-
* ]
58-
*/
108+
/*
109+
|--------------------------------------------------------------------------
110+
| Polymorphic relationships
111+
|--------------------------------------------------------------------------
112+
|
113+
| Define polymorphic relationships
114+
|
115+
| [
116+
| 'table_name' => 'polymorphic_type',
117+
|
118+
| ex. for official laravel documentation
119+
| 'posts' => 'commentable',
120+
| ]
121+
|
122+
*/
59123
'morphs' => [
60124
],
61125

62-
/**
63-
* Interface(s) implemented by all models
64-
*/
126+
/*
127+
|--------------------------------------------------------------------------
128+
| Interfaces
129+
|--------------------------------------------------------------------------
130+
|
131+
| Interface(s) implemented by all models
132+
|
133+
*/
65134
'interfaces' => [
66135
],
67136

68-
/**
69-
* Trait(s) used by all models
70-
*/
137+
/*
138+
|--------------------------------------------------------------------------
139+
| Traits
140+
|--------------------------------------------------------------------------
141+
|
142+
| Trait(s) implemented by all models
143+
|
144+
*/
71145
'traits' => [
72146
],
73147

74-
/**
75-
* Enum(s) used in laravel casts function
76-
*/
148+
/*
149+
|--------------------------------------------------------------------------
150+
| Enums
151+
|--------------------------------------------------------------------------
152+
|
153+
| Enum(s) implemented by all models
154+
|
155+
*/
77156
'enums_casting' => [
78157
],
79158

80-
/**
81-
* Excluded Tables
82-
*/
159+
/*
160+
|--------------------------------------------------------------------------
161+
| Excluded Tables
162+
|--------------------------------------------------------------------------
163+
|
164+
| These models will not be generated
165+
|
166+
*/
83167
'except' => [
84168
'migrations',
85169
'failed_jobs',

0 commit comments

Comments
 (0)
Please sign in to comment.