Zbigniew
Zbigniew
FFilament
Created by S.V Gubadov on 7/26/2023 in #❓┊help
Calculate the difference between 2 dates
Maybe it will be useful to someone. return $form ->schema([ Forms\Components\Select::make('customer_id') ->relationship('customer', 'full_name') ->required(), Forms\Components\DatePicker::make('rental_date')->label(__('Rental start date')) //->default(now()) ->required() ->live(true) ->afterStateUpdated(function (Get $get, Set $set) { self::updateTotalsDays($get, $set); }), Forms\Components\DatePicker::make('return_date')->label(__('Rental end date')) ->default(fn (Get $get) => $set('rental_date')) ->required() ->live(true) ->afterStateUpdated(function (Get $get, Set $set) { self::updateTotalsDays($get, $set); }), Forms\Components\TextInput::make('total_of_days') ->numeric() ->readOnly() ]); } public static function updateTotalsDays(Get $get, Set $set): void { $days = Carbon::parse($get('rental_date'))->diffInDays(Carbon::parse($get('return_date'))); $set('total_of_days', $days); }
16 replies
FFilament
Created by S.V Gubadov on 7/26/2023 in #❓┊help
Calculate the difference between 2 dates
No description
16 replies