Problem was I added a 'deleted_at
' column after I started the project and when I applied migrations, I didn't have softdeleting enabled. Obviously, I did a second error, forgetting to enable 'deleted_at
' to be nullable, hence all inserts went had a wrong timestamp (0000-00-00 ...).
Fix:
-
Made nullable '
deleted_at
' column. -
Set all wrong '
deleted_at
' timestamps toNULL
.
转自:https://stackoverflow.com/questions/26139886/laravel-eloquentfind-returning-null-with-an-existing-id