I'm using laravel 5.1 with eloquent, i have a postgre database and i would like to insert an object with some date in. My start format date is like '15/10/2015', and i need to convert into 'Y-m-d'.
For that i use date mutators in my model, i add this line :
protected $dates = ['created_at', 'updated_at', 'prj_start_date', 'prj_end_date_init'];
I use an architecture with services and repositories so in my repository for create my object in DB i have this :
$this->model->create($data);
When i try to insert i have this error
InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
Unexpected data found.
Data missing
in Carbon.php line 425
at Carbon::createFromFormat('Y-m-d H:i:s', '15/10/2015') in Model.php line 2959
at Model->asDateTime('15/10/2015') in Model.php line 2915
at Model->fromDateTime('15/10/2015') in Model.php line 2870
at Model->setAttribute('prj_start_date', '15/10/2015') in Model.php line 422
Why isn't work, i've miss something ? Can someone help me please ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire