Created
July 12, 2018 09:48
-
-
Save sasin91/fd8d3c0f48efbf266b3b43cf82e10e41 to your computer and use it in GitHub Desktop.
Factory model story with model states
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait HasModelStates | |
{ | |
/** | |
* The registered model states. | |
* | |
* @var array | |
*/ | |
protected $states = []; | |
/** | |
* Add some model states to pass down to the model factory. | |
* | |
* @param array|string $states | |
* @return $this | |
*/ | |
public function states($states) | |
{ | |
$this->states = array_merge($this->states, array_wrap($states)); | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment