I am using laravel created event. I want to use newly created id in another table. But when i print created object, i don't get the id property. How can i get newly created id in created event.
This is my code.
public static function booted()
{
static::created(function ($agentTask)
{
echo $agentTask->id;
print_r($agentTask);
});
}
echo statement printing null. and when i print $agentTask object, i don't find id anywhere.
it should be
boot
notbooted
booted
is used to perform any actions required after the model boots.while
boot
is used to bootstrap the model and its traits.Laravel API DOC: booted() boot()