*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'source' => $this->source, 'source_id' => $this->source_id, 'zip_code' => $this->zip_code, 'address' => $this->address, 'number' => $this->number, 'district' => $this->district, 'has_complement' => $this->has_complement, 'complement' => $this->complement, 'nickname' => $this->nickname, 'instructions' => $this->instructions, 'is_primary' => $this->is_primary, 'city_id' => $this->city_id, 'state_id' => $this->state_id, 'address_full' => implode(', ', array_filter([ $this->address, $this->number ? "nÂș {$this->number}" : null, $this->district, $this->city ? "{$this->city->name}/{$this->state?->code}" : null, ])), 'city' => $this->whenLoaded('city'), 'state' => $this->whenLoaded('state'), 'address_type' => $this->address_type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at, ]; } }