Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected data found. Trailing data

Tags:

php

laravel-5

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?

like image 904
Nguyễn Minh Huy Avatar asked Jan 19 '26 13:01

Nguyễn Minh Huy


1 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.

like image 172
Khem Raj Regmi Avatar answered Jan 21 '26 04:01

Khem Raj Regmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!