从评论中你可以清楚地看到。
如果一个属性是日期,我们将在转换后将其转换为字符串
到DateTime/Carbon实例。这样我们就能得到一些一致的
访问属性时格式化与排列/JSON模型。
这是一个例子。
return new HttPStatus(301);
让我们再看一个例子。
json_decode($string, true);
-
你能告诉我为什么我们要经过吗
true
.?
-
目的是什么。?
如果你没有经验
json_decode($string, true);
在里面
json_decode()
再举一个例子。
json_decode($string, $returnArray = true);
真的
它将返回一个数组。
$returnArray = true
同样的情况
// If an attribute is a date, we will cast it to a string after converting it
// to a DateTime / Carbon instance. This is so we will get some consistent
// formatting while accessing attributes vs. arraying / JSONing a model.
$attributes = $this->addDateAttributesToArray(
$attributes = $this->getArrayableAttributes()
);
$attributes = $this->getArrayableAttributes()
它只是一个一次性变量,告诉我们传递的是属性,这增加了代码的可读性。