I found that you should not use createFromFormat if the second parameter $date also not a Carbon object, but if it is not, and it is just a string, you can simply use
public function setPublishedAtAttribute($date){ $this->attributes['published_at'] = Carbon::parse($date); }
I think that there is a bit more overhead due to the fact that he needs to find out what format he is in, but this was my temporary solution.
'Ymd' is how the front parsed it in the form, but it gets into the database from which Carbon breaks out. I got the same error:
[2015-08-16 21:35:57] production.ERROR: exception 'InvalidArgumentException' with message 'Trailing data' in /Users/alexanderkleinhans/laravel/vendor/nesbot/carbon/src/Carbon/Carbon .php:414
I believe in the first part of the stack trace,
Carbon\Carbon::createFromFormat('Ym-d', Object(Carbon\Carbon))
indicates that the second parameter should be a Carbon object, so you might need to make sure this is a case in the form, not just date('Ym-d') , as in PHP.
source share