Skip to content

Commit 241163b

Browse files
carlos3duardoAdrianSkierniewski
authored andcommitted
Using EloquentTree in another database (#15)
I am working on a project with multiple databases. And we use the Eloquent Tree at one database who at not the application database default. This line code causes an error because the application it was looking at the table in the wrong database.
1 parent d2bc288 commit 241163b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Gzero/EloquentTree/Model/Observer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function saved(Tree $model)
3333
{
3434
if ($model->{$model->getTreeColumn('path')} === '') { // If we just save() new node
3535
$model->{$model->getTreeColumn('path')} = $model->getKey() . '/';
36-
DB::table($model->getTable())
36+
DB::connection($model->getConnectionName())->table($model->getTable())
3737
->where($model->getKeyName(), '=', $model->getKey())
3838
->update(
3939
array(

0 commit comments

Comments
 (0)