Closed BertKooij closed 4 years ago
this error is normally because the date format set on your model doesnt match your database
Thanks for looking into the error. I am very interested in more information about similar issues! But this issue is both raised when providing an explicit $dateformat
on the model and also when $dateformat
is not provided at all. I am currently looking into the reason why multiple formats are used.
Even when I format the deadline within the factory to the driver standard Y-m-d H:i:s.v
, the value is still being formatted to Y-m-d H:i:s
. Which than is used within the events where the activity gets logged. There HasAttributes->asDateTime($value)
is called and checked against the format from the database driver which than does not equals to the value and the exception is raised.
Well, summarized: it turned out that there was a accessor applied to deadline
which was returning in the wrong format. Issue solved!
Description:
Currently I am porting a project from a MySQL to a MSSQL database. But while seeding the database an exception was thrown for casting a date.
So far I discovered that the
HasAttributes
trait of Eloquent is falling back on the format from the database driver, which is not alway the case. See: https://github.com/illuminate/database/blob/master/Eloquent/Concerns/HasAttributes.php#L862In case of MSSQL this is
Y-m-d H:i:s.v
, but I assume the data is passed to theLogsActivity
trait without receiving data from the database since the date value actually equals to theY-m-d H:i:s
format once it hits theLogsActivity
trait from the laravel-activitylog package.Specifying a specific
$dateformat
within the model does not work since it raises an exception when the data is actually passed in theY-m-d H:i:s.v
format.Steps To Reproduce:
Model: task.php (simplified version)
TaskFactory.php (simplified version)
Call within seeder DemoDataSeeder.php
Stacktrace: