I kindly need your support to understand how to apply the same date format, as indicated in the original resource, to the belongsTo field in Laravel Nova 4.
Resource 1
public function fields(Request $request)
{
return [
ID::make('id')->sortable(),
Date::make('Shipment Eta Date')
->rules('required', 'date')
->placeholder('Shipment Eta Date')
->displayUsing(fn ($value) => $value ? $value->format('D d/m/Y') : ''),
HasMany::make('ShipmentInfos', 'shipmentInfos'),
];
}
Resource 2
public function fields(Request $request)
{
return [
ID::make('id')->sortable(),
Date::make('Shipment Sent Date')
->rules('required', 'date')
->placeholder('Shipment Sent Date')
->displayUsing(fn ($value) => $value ? $value->format('D d/m/Y') : ''),
HasMany::make('ShipmentInfos', 'shipmentInfos'),
];
Resource 3
BelongsTo::make('ShipmentSentDate', 'shipmentSentDate'),
BelongsTo::make('ShipmentEtaDate', 'shipmentEtaDate'),
I tried this, but it doesn't work:
BelongsTo::make('ShipmentSentDate', 'shipmentSentDate')
->displayUsing(fn ($value) => $value ? $value->format('D d/m/Y') : ''),
BelongsTo::make('ShipmentEtaDate', 'shipmentEtaDate')
->displayUsing(fn ($value) => $value ? $value->format('D d/m/Y') : ''),
I apologize for the inconvenience, and I would like to thank @Harris and @Karl Hill. Here's the solution:
Thank you.