if ($dataRaw['type'] == "CheckIn") {
$res = $this->fetchLocations($dataRaw['entityid'], 'checkins');
\App\CheckIn::create([
'type' => $dataRaw['type'],
'reason' => $dataRaw['checkinreason'],
'device_id' => $ssid,
'deviceuniqueidentifier' => $dataRaw['deviceuniqueidentifier'],
'date_time' => gmdate("Y-m-d H:i:s", hexdec(substr($dataRaw['entityid'], 0, 8))),
'entityid' => $dataRaw['entityid'],
'latitude' => $res['Latitude'],
'longitude' => $res['Longitude'],
'address' => $res['Address'],
'queue' => $k,
]);
}
if ($dataRaw['type'] == "Event") {
$res = $this->fetchLocations($dataRaw['entityid'], 'events');
\App\Events::create([
'type' => $dataRaw['type'],
'reason' => $dataRaw['eventtype'],
'device_id' => $ssid,
'deviceuniqueidentifier' => $dataRaw['deviceuniqueidentifier'],
'date_time' => gmdate("Y-m-d H:i:s", hexdec(substr($dataRaw['entityid'], 0, 8))),
'entityid' => $dataRaw['entityid'],
'queue' => $k,
'latitude' => $res['Latitude'],
'longitude' => $res['Longitude'],
'address' => $res['Address'],
]);
}
这是我进行查询的地方,它为最后三列纬度经度和地址发送空值。我还检查了 $res 数组中出现的值,它们也打印得很好。发布的日志中也没有错误。
事件.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Events extends Model
{
protected $table = 'events';
protected $fillable = ['type', 'reason', 'is_processed',
'device_id',
'deviceuniqueidentifier', 'date_time', 'entityid', 'queue',
'is_deleted'];
}
最佳答案
将这些列添加到可填充数组中,如下所示:
protected $fillable = [
'type',
'reason',
'is_processed',
'device_id',
'deviceuniqueidentifier',
'date_time',
'entityid',
'queue',
'is_deleted',
// follwing lines missing
'latitude',
'longitude',
'address',
];
提示:您可以使用$cast让列值重新运行为 true 或 false:
protected $casts = [
'is_processed' => 'boolean',
'is_deleted' => 'boolean'
];
关于php - postgresql 中的最后三列值在通过 php laravel 发送时变为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44037184/