Hello,
Ok, so I am trying to seed data into a table, below is what I have tried:
$factory->define(\App\Models\State::class, function(){
$client = new Client();
$stateQuery = $client->get('http://states-and-cities.com/api/v1/states');
$states = $stateQuery->getBody();
$states = json_decode($states, true);
foreach ($states as $state) {
return [
'name' => $state['name'],
];
}
});
This return only on state because well it's return. Is there some way I can do this?
why not just insert everything right in the seeder class, no need for a factory ?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community