当我第一次创建记录时,Laravel自动将updated_at和created_at列设置为正确,但是当我去更新记录时,它给了我一个“跟踪数据”错误,我想这与这两个字段有关。
我尝试手动插入updated_at字段,但这不起作用。
这是updateOrCreate代码。
$pixel = array(
'player' => $player,
'x' => $x,
'z'=> $z,
'color' => $color,
'material' => $material
);
Pixel::updateOrCreate(['x' => $x,'z' => $z],$pixel);
应该注意的是,我在“ x”和“ z”字段上的索引不明确。
这是像素模型。
class Pixel extends Model
{
protected $table = 'pixels';
protected $fillable = [
'player','x','z','color','material'
];
}
这是表格的样子。
https://i.imgur.com/4bHnOMo.png
这是完整的错误消息。
/home/forge/default/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php
// Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag.
if (!preg_match("/{$nonEscaped}[!|]/", $format)) {
$format = static::MOCK_DATETIME_FORMAT.' '.$format;
$time = ($mock instanceof self ? $mock->rawFormat(static::MOCK_DATETIME_FORMAT) : $mock->format(static::MOCK_DATETIME_FORMAT)).' '.$time;
}
// Regenerate date from the modified format to base result on the mocked instance instead of now.
$date = self::createFromFormatAndTimezone($format, $time, $tz);
}
if ($date instanceof DateTimeInterface) {
$instance = static::instance($date);
$instance::setLastErrors($lastErrors);
return $instance;
}
if (static::isStrictModeEnabled()) {
throw new InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
}
return false;
}
/**
* Create a Carbon instance from a specific format.
*
* @param string $format Datetime format
* @param string $time
* @param \DateTimeZone|string|false|null $tz
*
* @throws InvalidArgumentException
*
* @return static|false
*/
public static function createFromFormat($format, $time, $tz = null)
{
$function = static::$createFromFormatFunction;
Arguments
"Trailing data"