Level 12
where did you get this code?
factories like laravel docs: can you post the link to these Laravel docs, please
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to use closures on factories like laravel docs:
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'user_id' => User::factory(),
'user_type' => function (array $attributes) {
return User::find($attributes['user_id'])->type;
},
'title' => $this->faker->title(),
'content' => $this->faker->paragraph(),
];
}
But when I try to run a seeder that calls the factory I get "Object of class Closure could not be converted to string".
This feature isn't available at Lumen? I'm using Lumen 8.2.3
Please or to participate in this conversation.