Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Filament Cep Field

Filament Cep Field Laravel Package

jeffersongoncalves/filament-cep-field

Filament CEP Field adds a Brazilian postal code (CEP) input to Filament forms with automatic 99999-999 formatting, validation, and address lookup via BrasilAPI/ViaCEP/AwesomeAPI. Includes Laravel model caching, invalidation, queue support, and full Brazilian states mapping.

View on GitHub
Deep Wiki
Context7

The Filament CEP Field is a custom input component designed specifically for Brazilian postal codes (CEP - Código de Endereçamento Postal). This component extends Filament's form capabilities by providing a specialized input field that handles CEP formatting, validation, and automatic address lookup.

Frequently asked questions about Filament Cep Field
How do I add a CEP field to a Filament form?
Use the `CepInput::make()` method in your Filament form definition. For example: `CepInput::make('cep')->required()`. The field will automatically format the input as `99999-999` and validate the CEP format. You can also customize labels, error messages, and API provider settings.
Which CEP APIs does this package support?
The package supports multiple APIs out of the box: BrasilAPI, ViaCEP, and AwesomeAPI. You can configure the default API in the field settings or override it globally via the package configuration. Each API has different rate limits, so test which works best for your use case.
Does this package work with Laravel 10 and Filament 5.x?
Yes, this package is fully compatible with Laravel 10.x and Filament 5.3+. It leverages Filament’s form system and follows its conventions, ensuring smooth integration. Always check the package’s `composer.json` for the latest supported versions to avoid compatibility issues.
How does caching work for CEP lookups?
The package uses Laravel’s model caching to store CEP responses, reducing API calls and improving performance. Cache invalidation is handled automatically via queues, ensuring stale data doesn’t persist. You can configure cache TTL (time-to-live) and monitor cache hit rates for optimization.
Can I customize the address fields populated by the CEP lookup?
Yes, you can map the API response fields to your model attributes using the `map()` method. For example: `CepInput::make('cep')->map('street', 'street')->map('city', 'city')`. This allows you to control which address fields are populated in your Filament form.
What happens if the CEP API is down or returns an error?
The package falls back to cached responses if available. You can also configure custom error messages or retry logic. For critical applications, consider implementing a local CEP database fallback or monitoring API uptime to avoid disruptions.
How do I test this package in my CI/CD pipeline?
Use Laravel’s HTTP testing helpers like `Http::fake()` to mock API responses in your tests. For example: `Http::fake(['https://cep.awesomeapi.com.br/*' => Http::response(['street' => 'Test Street'])]);`. This ensures your tests run without external dependencies.
Is there a way to disable automatic address lookup?
Yes, you can disable the address lookup feature entirely by setting `enableLookup(false)` on the `CepInput` field. This is useful if you only need CEP validation without fetching additional address data. You can also disable it globally via package configuration.
Does this package support Brazilian state abbreviations?
Yes, the package includes full support for Brazilian state abbreviations (e.g., SP, RJ, MG). When a valid CEP is entered, the corresponding state will be automatically populated in the address fields. You can customize the state field mapping if needed.
What are the alternatives to this package for CEP handling in Laravel?
Alternatives include manually integrating with ViaCEP’s API using Laravel’s HTTP client or using packages like `spatie/laravel-cep`. However, those require more setup for form integration, validation, and caching. This package streamlines the process by providing a ready-to-use Filament component with built-in features like auto-formatting and caching.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor