New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relationship model uuid #33
Comments
@robertnicjoo am I right in understanding you have the following?
If so, what model is not having the |
this table |
@robertnicjoo so does the |
Yes it does have column |
@robertnicjoo I wouldn't expect this to work as you think, as it's ran as part of the As part of the $post->tags()->sync([
$tag1->id => ['id' => Ramsey\Uuid\Uuid\uuid4()->toString()],
]); |
Thank you I will try this. |
Working codes
$tags_id = (array) $request->input('tags');
foreach( $tags_id as $tag_id ) {
$post->tags()->sync([
$tag_id => ['id' => \Ramsey\Uuid\Uuid::uuid4()->toString()],
]);
}
$tags_id = (array) $request->input('tags');
foreach( $tags_id as $tag_id ) {
$tag_data_to_sync[ $tag_id ] = [ 'id' => \Ramsey\Uuid\Uuid::uuid4()->toString() ];
}
$post->tags()->sync( $tag_data_to_sync ); Note "86198680-1f0b-4544-851a-4c39e4f7c3ec,2bbe9776-7413-43fa-9cae-3378f39f3c2d" You need to explode them first before you loop them $tags_id = explode(',', $request->input('tags'));
foreach( $tags_id as $tag_id ) {
...
} |
I have relationship table that connects 2 other tables together (let say post _tags) this table only gets
id of post
andid of tags
therefore this table does not have model (doesn't need one), now when I store my post tags withsync()
method. It leavesid
column empty which cause errors while storing my posts.Any solution to that?
The text was updated successfully, but these errors were encountered: