public function makeArray() { if ($this->formatters !== null
) { $result =
[];
foreach ($this->formatters
as $field =>
$formatter) { $result[$field] =
$this->faker->
{$formatter}();
} } // If no formatters were defined then look for a model fake() method
elseif (method_exists($this->model, 'fake'
)) { $result =
$this->model->
fake($this->faker
);
$result =
is_object($result) &&
method_exists($result, 'toArray'
) // This should cover entities
?
$result->
toArray() // Try to cast it
:
(array) $result;
} // Nothing left to do but give up
else { throw new RuntimeException(lang('Fabricator.missingFormatters'
));
}