Skip to content

Commit

Permalink
[11.x] Add getConnection() Method to Factory Class for Retrieving Dat…
Browse files Browse the repository at this point in the history
…abase 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 <taylor@laravel.com>
  • Loading branch information
jonathanpmartins and taylorotwell authored Oct 21, 2024
1 parent 6247370 commit 57a35ec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Database/Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,16 @@ public function count(?int $count)
return $this->newInstance(['count' => $count]);
}

/**
* Get the name of the database connection that is used to generate models.
*
* @return string
*/
public function getConnectionName()
{
return $this->connection;
}

/**
* Specify the database connection that should be used to generate models.
*
Expand Down

0 comments on commit 57a35ec

Please sign in to comment.