Created
June 6, 2018 01:10
-
-
Save thmsbkkr/81e8f095365672efada406a1032b1a55 to your computer and use it in GitHub Desktop.
Functions for Laravel factories in tests
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 | |
function create($class, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->create($attributes); | |
} | |
function make($class, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->make($attributes); | |
} | |
function raw($class, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->raw($attributes); | |
} | |
function createState($class, $state, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->states($state)->create($attributes); | |
} | |
function makeState($class, $state, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->states($state)->make($attributes); | |
} | |
function rawState($class, $state, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->states($state)->raw($attributes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment