ExportColumn::make('operating_expenses'),
ExportColumn::make('operating_expenses') ->listAsJson(),
beforeValidate() function
castStateUsing()
"[{\"cost\":0,\"name\":\"Home inspection\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Appraisal\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Loan Points\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Lender Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Title & Escrow Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Transfer Taxes\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Attorney Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"},{\"cost\":0,\"name\":\"Wholesaler Fees\",\"in_loan\":0,\"percent\":0,\"cost_type\":\"set-amount\"}]"
->columns(['default' => 8]),
->columns(8),
Section::make() ->extraAttributes(['class' => 'overflow-x-scroll']) ->schema([ RepeatableEntry::make('calculationProjectionsFirstYear') ->label('Income') ->schema([ TextEntry::make('gross_rent') ->hiddenLabel(true) ->state('Gross Rent'), TextEntry::make('vacancy') ->hiddenLabel(true) ->state('Vacancy'), TextEntry::make('operating_income_total') ->hiddenLabel(true) ->state('Operating Income'), ]) ->contained(false) ->columnSpan(1), RepeatableEntry::make('calculationProjectionsFirstYear') ->label('Year 1') ->schema([ TextEntry::make('gross_rent') ->hiddenLabel(true) ->money('AED', 100), TextEntry::make('vacancy') ->hiddenLabel(true) ->prefix('- ') ->money('AED', 100), TextEntry::make('operating_income_total') ->hiddenLabel(true) ->prefix('= ') ->color(function ($state) { return $this->getFieldColor($state); }) ->money('AED', 100), ]) ->contained(false) ->columnSpan(1),More Repeatables
protected function beforeValidate(): void{ $this->data['purchase_costs'] = $this->parseCosts($this->data['purchase_costs']); $this->data['rehab_costs'] = $this->parseCosts($this->data['rehab_costs']); $this->data['other_income'] = $this->parseCosts($this->data['other_income']); } /** * Parse the costs. */ protected function parseCosts($costs) { if (empty($costs)) { return null; } return $this->tryParseCosts($costs); } /** * Try to parse the costs. */ protected function tryParseCosts($costs) { try { return json_decode($costs, true); } catch (\Exception $e) { return null; } }
protected function beforeValidate(): void{ $this->data['follow_up'] = $this->parseFollowUp($this->data['follow_up']);}/** * Parse the follow up date. */protected function parseFollowUp($followUp){ if (empty($followUp)) { return null; } try { return Carbon::parse($followUp)->getTimestamp(); } catch (\Exception $e) { return null; }}
try { $date = new \DateTime($value); $newState = $date->getTimestamp(); Log::info('Follow up date: ' . $newState); } catch (\Exception $e) { $newState = null; Log::info('Follow up date: ' . $newState); }