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
> **⚠️ IMPORTANT**: You must create Property definitions before setting property values. Attempting to set a property that doesn't have a definition will throw a `PropertyNotFoundException`.
69
+
68
70
### 1. Add the Trait to Your Models
69
71
70
72
```php
@@ -85,8 +87,10 @@ class User extends Model
85
87
86
88
### 2. Create Properties
87
89
90
+
**⚠️ REQUIRED STEP**: Before setting any property values, you must first create the property definitions. This ensures type safety, validation, and optimal performance.
91
+
88
92
```php
89
-
use YourVendor\DynamicProperties\Models\Property;
93
+
use SolutionForest\LaravelDynamicProperties\Models\Property;
90
94
91
95
// Create a text property
92
96
Property::create([
@@ -118,14 +122,19 @@ Property::create([
118
122
119
123
### 3. Set and Get Properties
120
124
125
+
**✅ Only after creating property definitions can you set values:**
126
+
121
127
```php
122
128
$user = User::find(1);
123
129
124
-
// Set properties
130
+
// ✅ This works - property 'phone' was defined above
Copy file name to clipboardExpand all lines: docs/API.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# API Documentation
2
2
3
+
> **⚠️ IMPORTANT**: Property definitions must be created before setting property values. All `setDynamicProperty` methods will throw `PropertyNotFoundException` if the property doesn't exist. Search methods (`whereProperty`) will work but fall back to less optimal type detection without property definitions.
4
+
3
5
## Table of Contents
4
6
5
7
-[Models](#models)
@@ -14,6 +16,37 @@
14
16
-[Facades](#facades)
15
17
-[Artisan Commands](#artisan-commands)
16
18
19
+
## Getting Started
20
+
21
+
### Property Definition Requirement
22
+
23
+
**All dynamic property operations require property definitions to exist first.** Here's what happens in each scenario:
24
+
25
+
| Operation | With Property Definition | Without Property Definition |
> **💡 BEST PRACTICE**: While this method works without property definitions (using fallback type detection), defining properties first ensures optimal performance and type safety.
0 commit comments