Skip to content

Commit 6d05cf2

Browse files
author
plokko
authored
Update DB_sync.md
1 parent e0f610c commit 6d05cf2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/DB_sync.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ class MyModel extends Model
3737

3838
}
3939
```
40+
### Changing reference name
41+
By default the model will be synchromized to Firebase using the table name (ex. User model using _users_ table will be sync to _/users_);
42+
you can change this behaivour by extending the `getFirebaseReferenceName` method and returning a custom reference name
43+
```php
44+
45+
/**
46+
* @return string reference name
47+
*/
48+
public function getFirebaseReferenceName(){
49+
return 'my_custom_reference';// default : $this->getTable();
50+
}
51+
```
52+
4053
## Sync related models
4154
Sometimes you want to serialize to firebase data from othe related models but the changes in the related model will not be automatically updated on the base model and vice-versa.
4255
You can extend the model synchronization to related models using the `SyncRelatedWithFirebase` trait in your Model and extend the `getRelationsToSyncWithFirebase()` function to return an array of relations you want to keep in sync

0 commit comments

Comments
 (0)