Answer the question
In order to leave comments, you need to log in
Laravel doesn't return id after object creation, why?
Hello.
I'm ready to tear my hair out on my head ->
when creating an object, I need to know the ID, according to my logic MyModel::create($data) should return a freshly created object, but it's not. Maybe it's in the settings?
$location = Location::create(['value' => $value]);
dd($location->id); //NULL
Answer the question
In order to leave comments, you need to log in
I found an error - according to an erroneous design, the ID was String and registered in the model. Now everything has changed, but I forgot one thing:
by removing this line I get an ID
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question