Format error while saving model in Laravel 5.5

Question:

Hello everyone,

On save / update model (in Laravel 5.5) with field

`updated_at` DATETIME NOT NULL,

I get an error

(1/1) InvalidArgumentException
Trailing data
in Carbon.php (line 582)
at Carbon::createFromFormat('Y-m-d', '2017-09-09 11:22:00')
in HasAttributes.php (line 715)
at Model->asDateTime('2017-09-09 11:22:00')
in HasAttributes.php (line 738)
at Model->fromDateTime('2017-09-09 11:22:00')
in HasAttributes.php (line 1062)
at Model->originalIsEquivalent('updated_at', '2017-09-09')
in HasAttributes.php (line 1023)
at Model->getDirty()
in Model.php (line 613)
at Model->performUpdate(object(Builder))
in Model.php (line 531)
at Model->save()
in Client.php (line 408)

The current value of the updated_at field in the database is '2017-09-09 11:22:00' and the line is of interest

at Carbon::createFromFormat('Y-m-d', '2017-09-09 11:22:00')

Looks like the problem is with the first parameter of the date format? Does this parameter need to be set somewhere in the settings?

Thanks !

Answer:

Do you mean tvk:

<?php

namespace App;

use Validator;
use DB;
use App\MyRestfulModel;
use App\Department;
use App\Order;
use App\ClientImage;
use App\Http\Traits\funcsTrait;
use App\library\ListingReturnData;

class Client extends MyRestfulModel
{
    protected $table = 'client';
    protected $primaryKey = 'client_id';
    protected $dateFormat = "Y-m-d H:i:s";
    ...

It does not help and the error remains …

Если добавить свойство

public $timestamps = false;

то поле updated_at не апдейтиться вовсе и, наверно, я могу добавить текущее время в updated_at поле при сохранении... 
Но есть лучше решение?

Эта  база не моя - и хотелось бы решения на стороне laravel без модификации таблицы...
Scroll to Top