laravel - Laravel Nova 从另一个字段引用字段值
问题描述
据我所知,要引用 Nova 字段,您可以在字段函数中使用 $this 对象。
所以我有这段代码,我的问题是这些值是空的,不应该:
- $this->origin_coordinates
- $this->destination_coordinates
即使我的索引页面显示字段 origin_coordinates 和 destination_coordinates 的值。
你知道为什么 Measure 字段是空的,这是基于我提到的字段。
谢谢,
BelongsTo::make('Warehouse')
->withoutTrashed()
->rules('required')
->sortable(),
BelongsTo::make('Customer')
->withoutTrashed()
->rules('required')
->sortable(),
BelongsToDependency::make('Consignee')
->dependsOn('customer', 'customer_id'),
Text::make('origin_coordinates', function() {
return $this->warehouse->longitude . ','. $this->warehouse->latitude;
}),
Text::make('destination_coordinates', function() {
return $this->consignee->longitude . ',' . $this->consignee->latitude;
}),
RouteMeasures::make('Measures') <---- Here is my problems this value is empty and should not
->route(
$this->origin_coordinates,
$this->destination_coordinates,
env('MAPBOX_ACCESS_TOKEN')
),
解决方案
推荐阅读
- angular - 如何跟踪 AOT 构建错误的问题(Angular 5.2.9)
- javascript - 在 jupyter notebook 中复制到剪贴板
- buffer - OpenCL:向 GPU 查询一组未知大小的结果
- r - 在 macOS Mojave 中安装 R 包:if (nzchar(SHLIB_LIBADD)) 中的错误
- php - 使用 queryBuilder 按字符串值排序的 Phalcon
- sql-server - SQL:如果连接返回多个匹配项,则仅删除一行
- angular - 从多个资源请求数据
- powershell - 如何将不同的 Powershell 宏合并为一个?
- listview - ListView 在向上/向下滚动时滞后
- c# - 将异步方法的结果分配给变量