Comments (9)
Yes I'm closing this. Thanks for the help.
from laravel-firebase.
What component are you referring to? Please provide a code example so that I can understand what you mean and replicate the behaviour.
from laravel-firebase.
$child = app('firebase.firestore')->database()->collection('Child')->newDocument();
$child->set([
'name' => 'John',
]);
$parent = app('firebase.firestore')->database()->collection('Parent')->newDocument();
$parent->set([
'Child' => \Google\Cloud\Firestore\FieldValue::arrayUnion([$child->path()])
]);
OR
$parent = app('firebase.firestore')->database()->collection('Parent')->newDocument();
$parent->set([
'Child' => $child->path()
]);
I want to set reference as datatype. Not string
from laravel-firebase.
Hi @jeromegamez, did you get my question?
from laravel-firebase.
Sorry for the late reply… unfortunately, I'm not super familiar with the Firestore component (this SDK just provides an entrypoint to google/cloud-firestore, but as far as I know it's not possible for a document to have a child - only collections can have children. You can see this in https://github.com/googleapis/google-cloud-php/blob/master/Firestore/src/DocumentReference.php#L70
So, if you wanted to have a reference between two documents, then using path strings and parsing them in your application would be the way to go.
I might be wrong - to be sure, I'd suggest asking the question again on StackOverflow or, if you think that this should be possible, as a feature request on https://github.com/googleapis/google-cloud-php/issues
I hope this helps!
from laravel-firebase.
ok @jeromegamez , thanks for all input you gave. it helps us in one or another way.
Now just to clear what we want to is send datatype of field.
As you can see in screenshot, there are many datatypes of a field. like from string, boolean etc.
There is one called "reference". We want to have this datatype.
As we send path, it always considered as string.
from laravel-firebase.
I just dug a little bit through the source code... could you try this?
$child = app('firebase.firestore')->database()->collection('Child')->newDocument();
$parent = app('firebase.firestore')->database()->collection('Parent')->newDocument();
$parent->set([
'Child' => $child
]);
It looks like the Firestore library could be capable of resolving this correctly, see https://github.com/googleapis/google-cloud-php/blob/master/Firestore/src/ValueMapper.php#L310.
I don't know if the child document has to be saved beforehand though.
from laravel-firebase.
Thanks a lot @jeromegamez . It worked.
And I have checked the case the child document set method is to be called beforehand. Else it stores reference with child id but that child is not created.
from laravel-firebase.
🎉Glad I could help! Would it be okay for you if we close this issue?
from laravel-firebase.
Related Issues (20)
- Callable functions
- SenderId mismatch HOT 7
- Laravel error HOT 2
- getting error HOT 1
- Incompatibility with Eloquent Resources? HOT 1
- Confirm email verification Support
- Its not supported php 8. Please fix this
- Push notifications are not getting displayed in IOS and Android randomly HOT 1
- Be able to override FirestoreClient::DEFAULT_DATABASE HOT 7
- Support PHP8.3 HOT 2
- Firestore insert or update problem when using laravel-octane HOT 3
- Auto discovery not working similar to v4.x HOT 5
- Cannot mock final class for phpunit tests as it's return type is other final class HOT 1
- Support symfony/cache version 7 HOT 3
- Make Support For Laravel 11 HOT 2
- Curl error on Laravel 11 HOT 9
- laravel publish issue HOT 1
- Unable to install kreait/laravel-firebase on Laravel 11 project HOT 1
- Binding Error with 5.9 HOT 2
- Log Channel Not Working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-firebase.