im having trouble mass updating data with tinker and Carbon as it does not iterate through the values
input
>>> $d = Child::get('Birthday') //1st command
[!] Aliasing 'Child' to 'App\Child' for this Tinker session.
=> Illuminate\Database\Eloquent\Collection {#4195
all: [
App\Child {#4196
Birthday: "2015-03-26",
},
App\Child {#4197
Birthday: "2014-08-16",
},
App\Child {#4198
Birthday: "2018-02-05",
},
App\Child {#4199
Birthday: "1976-08-26",
},
App\Child {#4200
Birthday: "1978-02-20",
},
App\Child {#4201
Birthday: "2011-06-09",
},
],
}
>>> foreach($d as $ad) Child::query()->update(['Birthday' => Carbon\Carbon::parse($ad->Birthday)->format('Y:m:d')]) //2nd command
heres the result
Illuminate\Database\Eloquent\Collection {#4204
all: [
App\Child {#4205
Birthday: "2011:06:09",
},
App\Child {#4206
Birthday: "2011:06:09",
},
App\Child {#4207
Birthday: "2011:06:09",
},
App\Child {#4208
Birthday: "2011:06:09",
},
App\Child {#4209
Birthday: "2011:06:09",
},
App\Child {#4210
Birthday: "2011:06:09",
},
],
}
I just want to mass update the date format but as u can see it updates everything wrong