File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ trait InteractsWithModelFactory
1818{
1919 protected ?ModelFactory $ modelFactory = null ;
2020
21- protected string |array $ factoryPath = BASE_PATH . '/database/factories ' ;
21+ /**
22+ * @var string|string[]
23+ */
24+ protected $ factoryPath = BASE_PATH . '/database/factories ' ;
2225
2326 protected function setUpInteractsWithModelFactory ()
2427 {
Original file line number Diff line number Diff line change @@ -28,22 +28,27 @@ public static function create(Generator $faker)
2828 return new static (new Factory ($ faker ));
2929 }
3030
31+ public function define (string $ class , callable $ attributes , string $ name = 'default ' ): void
32+ {
33+ $ this ->factory ->define (...func_get_args ());
34+ }
35+
3136 /**
32- * @param class-string<T> $model
37+ * @param class-string<T> $class
3338 * @return T
3439 */
35- public function factory (string $ model , ... $ arguments )
40+ public function factory (string $ class )
3641 {
37- $ factory = $ this -> factory ;
42+ $ arguments = func_get_args () ;
3843
3944 if (isset ($ arguments [1 ]) && is_string ($ arguments [1 ])) {
40- return $ factory ->of ($ arguments [0 ], $ arguments [1 ])->times ($ arguments [2 ] ?? null );
45+ return $ this -> factory ->of ($ arguments [0 ], $ arguments [1 ])->times ($ arguments [2 ] ?? null );
4146 }
4247 if (isset ($ arguments [1 ])) {
43- return $ factory ->of ($ arguments [0 ])->times ($ arguments [1 ]);
48+ return $ this -> factory ->of ($ arguments [0 ])->times ($ arguments [1 ]);
4449 }
4550
46- return $ factory ->of ($ arguments [0 ]);
51+ return $ this -> factory ->of ($ arguments [0 ]);
4752 }
4853
4954 public function load (string $ path ): void
You can’t perform that action at this time.
0 commit comments