本文整理匯總了PHP中DbUtil::serializeRoutePoint方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbUtil::serializeRoutePoint方法的具體用法?PHP DbUtil::serializeRoutePoint怎麽用?PHP DbUtil::serializeRoutePoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DbUtil
的用法示例。
在下文中一共展示了DbUtil::serializeRoutePoint方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: serializeRoute
public static function serializeRoute($route)
{
if (!empty($route)) {
$points = $route->points;
$origins = [];
$destinations = [];
foreach ($points as $point) {
if ($point->type === 'start') {
$origins[] = $point;
} else {
$destinations[] = $point;
}
}
return ['id' => $route->id, 'ride_id' => $route->ride_id, 'user_id' => $route->user_id, 'state' => $route->state, 'direction' => json_decode($route->direction), 'origins' => array_map(function ($x) {
return DbUtil::serializeRoutePoint($x);
}, $origins), 'destinations' => array_map(function ($x) {
return DbUtil::serializeRoutePoint($x);
}, $destinations), 'share_details' => ['arrival_time' => $route->endTime, 'notes' => $route->note]];
} else {
return [];
}
}