File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
src/Illuminate/Database/Eloquent/Factories Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -483,6 +483,18 @@ public function state($state)
483483 ]);
484484 }
485485
486+ /**
487+ * Set a single model attribute.
488+ *
489+ * @param string|int $key
490+ * @param mixed $value
491+ * @return static
492+ */
493+ public function set ($ key , $ value )
494+ {
495+ return $ this ->state ([$ key => $ value ]);
496+ }
497+
486498 /**
487499 * Add a new sequenced state transformation to the model definition.
488500 *
Original file line number Diff line number Diff line change @@ -108,6 +108,10 @@ public function test_basic_model_can_be_created()
108108 $ this ->assertInstanceOf (Eloquent::class, $ user );
109109 $ this ->assertSame ('Taylor Otwell ' , $ user ->name );
110110
111+ $ user = FactoryTestUserFactory::new ()->set ('name ' , 'Taylor Otwell ' )->create ();
112+ $ this ->assertInstanceOf (Eloquent::class, $ user );
113+ $ this ->assertSame ('Taylor Otwell ' , $ user ->name );
114+
111115 $ users = FactoryTestUserFactory::new ()->createMany ([
112116 ['name ' => 'Taylor Otwell ' ],
113117 ['name ' => 'Jeffrey Way ' ],
You can’t perform that action at this time.
0 commit comments