diff --git a/src/Illuminate/Database/Eloquent/Builder.php b/src/Illuminate/Database/Eloquent/Builder.php index b4825a489a7d..09d51a35befd 100755 --- a/src/Illuminate/Database/Eloquent/Builder.php +++ b/src/Illuminate/Database/Eloquent/Builder.php @@ -643,7 +643,7 @@ protected function isNestedUnder($relation, $name) public function cursor() { foreach ($this->applyScopes()->query->cursor() as $record) { - yield $this->model->newFromBuilder($record); + yield $this->newModelInstance()->newFromBuilder($record); } } diff --git a/tests/Database/DatabaseEloquentIntegrationTest.php b/tests/Database/DatabaseEloquentIntegrationTest.php index d4eaf622801e..db36a6cec349 100644 --- a/tests/Database/DatabaseEloquentIntegrationTest.php +++ b/tests/Database/DatabaseEloquentIntegrationTest.php @@ -184,6 +184,7 @@ public function testBasicModelRetrieval() $models = EloquentTestUser::where('id', 1)->cursor(); foreach ($models as $model) { $this->assertEquals(1, $model->id); + $this->assertEquals('default', $model->getConnectionName()); } $records = DB::table('users')->where('id', 1)->cursor();