You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ Optionally if you don't want to expose some models as resources but, you want to
124
124
];
125
125
````
126
126
127
-
For model properties autocomplete:
127
+
**Active Record Segregation of Properties:** for model attributes(columns) autocomplete and to avoid clashes with the model properties or relations:
128
128
129
129
- extend BaseModelAttributes following the same FQN structure as the parent's:
130
130
@@ -133,7 +133,18 @@ For model properties autocomplete:
133
133
134
134
- add in its class dock block using **@property** all the models properties/attributes/columns
135
135
- add in the model's class dock block **@property ChildBaseModelAttributes $a** and **@mixin ChildBaseModelAttributes**
136
-
- use **$model->a->** instead of **$model->**
136
+
- use `$model->a->` instead of `$model->` _(this will work without autocomplete even if you don't do the above)_
137
+
138
+
**Active Record Segregation of Properties:** for model relation autocomplete and to avoid clashes with the model properties and attributes(columns):
139
+
140
+
- extend BaseModelRelations following the same FQN structure as the parent's:
141
+
142
+
\App\Models\ChildBaseModel paired with \App\Models\Attributes\ChildBaseModelRelations
143
+
\App\Models\Folder\ChildBaseModel paired with \App\Models\Folder\Attributes\ChildBaseModelRelations
144
+
145
+
- add in its class dock block using **@property-read** all the models relations
146
+
- add in the model's class dock block **@property ChildBaseModelRelations $r** and **@mixin ChildBaseModelRelations**
147
+
- use `$model->r->` instead of `$model->` _(this will work without autocomplete even if you don't do the above)_
137
148
- BaseModelFrozenAttributes can be also extended on the same logic and used for model read only situations - DTO without setters (Reflection or Closure binding usage will retrieve/set protected stdClass not Model - but the model can be retrieved from DB by its primary key that is readable in this frozen model):
138
149
```php
139
150
#OperationModel example for BaseModelFrozenAttributes
@@ -279,7 +290,7 @@ for example for lumen:
279
290
280
291
OBS
281
292
282
-
Set `$returnNullOnInvalidColumnAttributeAccess = false;` in model if you want exception instead of null on accessing invalid model attributes (It also needs error_reporting = E_ALL in php ini file).
293
+
Set `$returnNullOnInvalidColumnAttributeAccess = false;` in model if you want exception instead of null on accessing invalid model attributes or invalid relations (It also needs error_reporting = E_ALL in php ini file).
283
294
284
295
Set LIVE_MODE=false in your .env file for non prod environments.
0 commit comments