Skip to content

Instantly share code, notes, and snippets.

@thmsbkkr
Created June 6, 2018 01:10
Show Gist options
  • Save thmsbkkr/81e8f095365672efada406a1032b1a55 to your computer and use it in GitHub Desktop.
Save thmsbkkr/81e8f095365672efada406a1032b1a55 to your computer and use it in GitHub Desktop.
Functions for Laravel factories in tests
<?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