Skip to content

Commit 57a35ec

Browse files
[11.x] Add getConnection() Method to Factory Class for Retrieving Database Connection (#53237)
* Add a getter to get the connection of a Factory * Test for getConnection() method inside the Illuminate\Database\Eloquent\Factories\Factory class * return correct type docblock * Update Factory.php * Update DatabaseEloquentFactoryTest.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 6247370 commit 57a35ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Illuminate/Database/Eloquent/Factories/Factory.php

+10
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,16 @@ public function count(?int $count)
728728
return $this->newInstance(['count' => $count]);
729729
}
730730

731+
/**
732+
* Get the name of the database connection that is used to generate models.
733+
*
734+
* @return string
735+
*/
736+
public function getConnectionName()
737+
{
738+
return $this->connection;
739+
}
740+
731741
/**
732742
* Specify the database connection that should be used to generate models.
733743
*

0 commit comments

Comments
 (0)