Skip to content

Instantly share code, notes, and snippets.

@sasin91
Created July 12, 2018 09:48
Show Gist options
  • Save sasin91/fd8d3c0f48efbf266b3b43cf82e10e41 to your computer and use it in GitHub Desktop.
Save sasin91/fd8d3c0f48efbf266b3b43cf82e10e41 to your computer and use it in GitHub Desktop.
Factory model story with model states
<?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