Reputation: 1073
I have the model:
$tour = new Tour();
After I add data to object $tour
:
$tour->date_start_at = $request->date_start_at;
$tour->date_end_at = $request->date_end_at;
$tour->save();
The fields date_start_at
and tour->date_end_at
are datetime
type in database.
Also in my model I have:
protected $dates = ['created_at', 'updated_at','date_start_at', 'date_end_at'];
When I try to save it I get:
InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
Unexpected data found.
Data missing
Upvotes: 0
Views: 199
Reputation: 6412
Use Carbon to parse the data:
$tour->date_start_at = Carbon::parse($request->date_start_at);
$tour->date_end_at = Carbon::parse($request->date_end_at);
$tour->save();
Upvotes: 1