Skip to content
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

Cloning into another database #4

Closed
icsStudentAcc opened this issue Jul 20, 2016 · 2 comments
Closed

Cloning into another database #4

icsStudentAcc opened this issue Jul 20, 2016 · 2 comments

Comments

@icsStudentAcc
Copy link

Hello,
I am trying to clone into another database.
$duplicate = Ticket::where('id',$id)->first()->setConnection('mysql2')->duplicate();
but it will not duplicate into the other database and duplicates to the default database. Please tell me how I can duplicate into another database.

@weotch
Copy link
Member

weotch commented Jul 20, 2016

Huh! I never considered doing that. I used Laravel's replicate to do the cloning: https://laravel.com/api/5.2/Illuminate/Database/Eloquent/Model.html#method_replicate. And then a normal save(). That may help you look into it further and submit a PR.

@weotch
Copy link
Member

weotch commented Aug 23, 2016

Looks like Laravel has some issues with relationships and multiple database connections: laravel/framework#9355. Looking more into this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants