I would kindly need your kind support to know how to put the same date format indicated in the original resource in the belongsto field in Laravel nova 4.
- Resource 1: Shipment Sent Date i got this. 30/01/2011
- Resource 2: Shipment Eta Date i got this. 08/12/2014
- Resource 3: Shipment Infos i got this :
2011-01-30 00:00:00
2014-12-08 00:00:00
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'),
];
Resources 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') : ''),
Thank you