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
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -394,7 +394,9 @@ It is possible to have relationships between native Laravel Model objects from y
394
394
protected $connection = 'theConnectionName';
395
395
```
396
396
397
-
Once they're set correctly, you can create relationships, such as a belongsTo, by manually creating a new eloquent-filemaker belongsTo object and setting the appropriate keys.
397
+
Once they're set correctly, you can create relationships, such as a belongsTo, by manually creating a new eloquent-filemaker belongsTo object or importing a new trait and setting the appropriate keys.
398
+
399
+
### Manually creating a relationship
398
400
399
401
Here is an example of setting a native Laravel User Model to belong to a FileMaker-based Company FMModel class.
400
402
@@ -410,6 +412,26 @@ class User extends Model
410
412
}
411
413
```
412
414
415
+
### Using trait to create a relationship (2.3.0+)
416
+
Here is an example of using the trait to create a native Laravel User Model to belong to a FileMaker-based Company FMModel class.
417
+
418
+
```php
419
+
// User.php
420
+
421
+
use GearboxSolutions\EloquentFileMaker\Database\Eloquent\Concerns\HasHybridRelationships;
422
+
423
+
class User extends Model
424
+
{
425
+
use HasHybridRelationships;
426
+
427
+
public function company()
428
+
{
429
+
// This method looks at the related model and determines the correct relationship type
0 commit comments