Unexpected data found. Trailing data

Viewed 14815

I'm trying to persist data from the client to my database and I have a trouble with the timestamp.

public function post(UpdateRequest $request){
    $update = new UpdateEvent();
    $update->src = $request->get('src');
    $update->title = $request->get('title');
    $update->sapo = $request->get('description');
    $update->created_at = $request->get('created_at');
    $update->img = $request->get('image');
    $update->save();
    return view('update.notification');
}

I'm getting the following exception:

InvalidArgumentException in Carbon.php line 582:
Unexpected data found.
Trailing data

Can you help me?

2 Answers

When a column is considered a date, you may set its value to a UNIX timestamp, date string (Y-m-d), date-time string, and of course a DateTime / Carbon instance, and the date's value will automatically be correctly stored in your database:

Source.

When a column is considered a date, you may set its value to a UNIX timestamp, date string (Y-m-d), date-time string, and of course a DateTime / Carbon instance, and the date's value will automatically be correctly stored in your database:

I'm not sure of the correct fix but I think the current issue is because this field is listed in $dates. Try to remove it from $dates array in your model.

Related