*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'unit_id' => $this->unit_id, 'transaction_type' => $this->transaction_type, 'from_account_id' => $this->from_account_id, 'to_account_id' => $this->to_account_id, // Banco da movimentação (destino na entrada, origem na saída). 'account_id' => $this->transaction_type === 'entrada' ? $this->to_account_id : $this->from_account_id, 'description' => $this->description, 'amount' => (float) $this->amount, 'launch_date' => $this->launch_date, 'origin' => $this->origin, 'is_reconciled' => (bool) $this->is_reconciled, 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'), 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'), ]; } /** * @param \Illuminate\Database\Eloquent\Collection $resource * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public static function collection($resource): AnonymousResourceCollection { return parent::collection($resource); } }