Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Created October 28, 2017 19:35
Show Gist options
  • Select an option

  • Save deleugpn/6190278cfe313c7849d2a5d3513d4549 to your computer and use it in GitHub Desktop.

Select an option

Save deleugpn/6190278cfe313c7849d2a5d3513d4549 to your computer and use it in GitHub Desktop.
<?php
/**
* @param $class
* @param array $attributes
* @param int $times
* @return mixed
*/
function create($class, $attributes = [], $times = 1)
{
$data = factory($class)->times($times)->create($attributes);
if ($times > 1) {
return $data;
}
return $data->first();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment