PHPackages                             kreatif/laravel-codice-fiscale - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. kreatif/laravel-codice-fiscale

ActiveLibrary[Localization &amp; i18n](/categories/localization)

kreatif/laravel-codice-fiscale
==============================

A comprehensive Laravel package for Italian Codice Fiscale (Tax Code) with Filament PHP v4 integration, validation, and multilingual geo-location support

v1.1.0(3mo ago)015↓90%[1 PRs](https://github.com/kreatifIT/laravel-codice-fiscale/pulls)MITPHPPHP ^8.2|^8.3|^8.4

Since Feb 2Pushed 3mo agoCompare

[ Source](https://github.com/kreatifIT/laravel-codice-fiscale)[ Packagist](https://packagist.org/packages/kreatif/laravel-codice-fiscale)[ Docs](https://github.com/kreatifIT/laravel-codice-fiscale)[ RSS](/packages/kreatif-laravel-codice-fiscale/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (16)Versions (7)Used By (0)

Laravel Codice Fiscale Package
==============================

[](#laravel-codice-fiscale-package)

A comprehensive Laravel package for Italian Codice Fiscale (Tax Code) with Filament PHP v5 integration, validation, and multilingual geo-location support.

Features
--------

[](#features)

- ✅ **Unified Geo-Location Database**: Single table for Italian municipalities AND foreign states
- ✅ **Multilingual Support**: Italian, German, and English denominations
- ✅ **Action-Based Architecture**: Reusable actions for all operations
- ✅ **Validation Rules**: Both basic and strict validation against personal data
- ✅ **Console Commands**: Easy data synchronization from official ANPR sources
- ✅ **Alto Adige / Südtirol Support**: Special handling for bilingual region
- ✅ **Caching**: Built-in caching for Belfiore code lookups
- ✅ **Filament v5 Field Component**: Full-featured custom field with generator and validator
- ✅ **Filament Form Fields Trait**: Ready-to-use trait with all CF fields (firstname, lastname, DOB, gender, country, place, CF)

Requirements
------------

[](#requirements)

- PHP 8.2 | 8.3 | 8.4+
- Laravel 11.x | 12.x
- Filament 5.x (for previous version v1.0.0)
- Database: MySQL, PostgreSQL, MariaDB, or SQLite

Installation
------------

[](#installation)

```
composer require kreatif/laravel-codice-fiscale
```

Quick Start
-----------

[](#quick-start)

### 1. Publish Configuration

[](#1-publish-configuration)

```
php artisan vendor:publish --tag=codice-fiscale-config
```

### 2. Run Migrations

[](#2-run-migrations)

```
php artisan migrate
```

### 3. Sync Data

[](#3-sync-data)

```
php artisan codice-fiscale:sync-geo-locations
```

**You might need to configure the `data_sources.csv.*.source` to this `__DIR__ . '/../vendor/kreatif/laravel-codice-fiscale/resources/data/csv/COL_VW_COMUNI_NAZIONI_ESTERE.csv'`.**

### 4. (Optional) Publish German Translation Data

[](#4-optional-publish-german-translation-data)

```
php artisan vendor:publish --tag=codice-fiscale-data
```

Usage
-----

[](#usage)

### Calculate Codice Fiscale

[](#calculate-codice-fiscale)

```
use Kreatif\CodiceFiscale\Actions\CalculateCodiceFiscale;

$codiceFiscale = CalculateCodiceFiscale::calculate([
    'firstname' => 'Mario',
    'lastname' => 'Rossi',
    'dob' => '1990-01-01',
    'gender' => 'M',
    'pob' => 'Roma', // or codice_catastale like 'z222'.
]);

// Result: RSSMRA90A01H501Z
```

### Validate Codice Fiscale

[](#validate-codice-fiscale)

```
use Kreatif\CodiceFiscale\Actions\ValidateCodiceFiscale;

// Basic validation (format and checksum)
$isValid = ValidateCodiceFiscale::isValid('RSSMRA90A01H501Z');

// Strict validation (compares against personal data)
$isValid = ValidateCodiceFiscale::isValidStrict('RSSMRA90A01H501Z', [
    'firstname' => 'Mario',
    'lastname' => 'Rossi',
    'dob' => '1990-01-01',
    'gender' => 'M',
    'pob' => 'Roma',
]);
```

### Find Belfiore Code

[](#find-belfiore-code)

```
use Kreatif\CodiceFiscale\Actions\FindBelfioreCode;

$code = FindBelfioreCode::find('Roma'); // Returns: H501
$code = FindBelfioreCode::find('Bozen'); // Returns: A952 (German name)
$code = FindBelfioreCode::find('Germany'); // Returns: Z112 (English name)
```

### Laravel Validation

[](#laravel-validation)

#### Basic Validation

[](#basic-validation)

```
use Kreatif\CodiceFiscale\Rules\ValidCodiceFiscale;

$validator = Validator::make($data, [
    'codice_fiscale' => ['required', 'string', new ValidCodiceFiscale],
]);

// Or use string-based rule:
$validator = Validator::make($data, [
    'codice_fiscale' => 'required|string|codice_fiscale',
]);
```

#### Strict Validation

[](#strict-validation)

```
use Kreatif\CodiceFiscale\Rules\CodiceFiscaleMatchesData;

$validator = Validator::make($data, [
    'first_name' => 'required|string',
    'last_name' => 'required|string',
    'dob' => 'required|date',
    'gender' => 'required|in:M,F',
    'pob' => 'required|string',
    'codice_fiscale' => [
        'required',
        new CodiceFiscaleMatchesData([
            'firstname' => 'first_name',
            'lastname' => 'last_name',
            'dob' => 'dob',
            'gender' => 'gender',
            'pob' => 'pob',
        ])
    ],
]);

// Or with default field names:
$validator = Validator::make($data, [
    'codice_fiscale' => 'required|codice_fiscale_matches',
]);
```

### Query Geo-Locations

[](#query-geo-locations)

```
use Kreatif\CodiceFiscale\Models\GeoLocation;

// Get all Italian municipalities
$comuni = GeoLocation::comuni()->valid()->get();

// Get municipalities
$altoAdige = GeoLocation::comuni()->get();

// Get all foreign states
$foreignStates = GeoLocation::foreignStates()->get();
```

Console Commands
----------------

[](#console-commands)

### Sync Municipalities

[](#sync-municipalities)

```
# Sync only Countries
php artisan codice-fiscale:sync-geo-locations --type=stato

# Sync only muncipalities
php artisan codice-fiscale:sync-geo-locations --type=comune
```

Documentation
-------------

[](#documentation)

Comprehensive documentation is available in the `.docs/` directory:

- **[README.md](.docs/README.md)** - Package overview and quick start
- **[DEV\_NOTES.md](.docs/DEV_NOTES.md)** - Development notes and future enhancements

Filament Integration
--------------------

[](#filament-integration)

### Filament Form Fields Trait

[](#filament-form-fields-trait)

The package provides a ready-to-use trait with pre-built Filament form fields for all Codice Fiscale data.

#### Out-of-the-Box (Simplest)

[](#out-of-the-box-simplest)

```
use Kreatif\CodiceFiscale\Filament\Forms\Traits\HasUserBasicFilamentFields;

class UserForm
{
    use HasUserBasicFilamentFields;

    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            ...self::getAllCodiceFiscaleFields(),
            // Your other fields...
        ]);
    }
}
```

This single line gives you:

- ✅ Firstname &amp; Lastname fields (grouped, responsive)
- ✅ Date of Birth with format (configurable creating format lang/{de,it,en,etc}/formats.php)
- ✅ Gender selector (M/F)
- ✅ Country of Birth (searchable, live updates)
- ✅ Place of Birth (dynamic: Select for Italy, TextInput for other countries)
- ✅ Codice Fiscale field with strict validation
- ✅ Multilingual labels (IT, EN, DE)

#### With Generator &amp; Validator

[](#with-generator--validator)

```
...self::getAllCodiceFiscaleFields(
    enableCFGenerator: true,
    enableCFValidator: true,
)
```

#### Individual Field Methods

[](#individual-field-methods)

For more control, use individual field methods:

```
use Kreatif\CodiceFiscale\Filament\Forms\Traits\HasUserBasicFilamentFields;

class UserForm
{
    use HasUserBasicFilamentFields;

    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            self::getFirstnameField(),
            self::getLastnameField(),
            self::getDOBField(),
            self::getGenderField(),
            self::getCountryOfBirthField(),
            self::getPlaceOfBirthField(),
            self::getCodiceFiscaleField(
                enableGenerator: true,
                enableValidator: true
            ),
        ]);
    }
}
```

#### Composed Field Groups

[](#composed-field-groups)

```
self::getNameFields(),          // Firstname + Lastname (grouped)
...self::getBirthFields(),      // DOB + Gender + Country + Place
self::getCodiceFiscaleField(),
```

#### Label Customization

[](#label-customization)

All fields support label customization:

```
// Use package labels (default)
self::getFirstnameField()

// Custom label
self::getFirstnameField(label: 'Your First Name')

// No label
self::getFirstnameField(label: false)

// Use your own translation key
self::getFirstnameField(label: __('my-app.firstname'))
```

Available label getter methods:

```
self::getFirstnameLabel()       // Returns translated label
self::getLastnameLabel()
self::getDOBLabel()
self::getGenderLabel()
self::getCountryOfBirthLabel()
self::getPlaceOfBirthLabel()
self::getCodiceFiscaleLabel()
```

```
                self::getfirstNameField('firstname'),
                self::getLastNameField('lastname'),
                self::getDOBField('dob'),
                self::getGenderField('gender'),
                self::getCountryOfBirthField('cob'),
                self::getPlaceOfBirthField('pob', true, 'cob'),
                self::getCodiceFiscaleField()
//                    ->strict([ // in case the name of the fields are changed, and activate validation of CF, you  need to specify the name of the fields
//                        'firstname' => 'first_name',
//                        'lastname' => 'last_name',
//                        'dob' => 'dob',
//                        'gender' => 'gender',
//                        'cob' => 'cob',
//                        'pob' => 'pob',
//                    ])
                ,

```

#### Dynamic Place of Birth

[](#dynamic-place-of-birth)

The Place of Birth field automatically switches between:

- **Select dropdown** when country is Italy (searchable Italian municipalities)
- **Text input** when country is anything else (free text for foreign locations)

This happens automatically based on the Country of Birth field value.

### CodiceFiscale Field Component

[](#codicefiscale-field-component)

#### Basic Usage

[](#basic-usage)

```
use Kreatif\CodiceFiscale\Filament\Forms\Components\CodiceFiscale;

// Simple field
CodiceFiscale::make('codice_fiscale');

// With generator and validator
CodiceFiscale::make('codice_fiscale')
    ->generator()
    ->validator();
```

#### Full-Featured with Strict Validation

[](#full-featured-with-strict-validation)

```
CodiceFiscale::make('codice_fiscale')
    ->generator()      // Enable generator modal
    ->validator()      // Enable validator button
    ->strict([         // Enable strict validation
        'firstname' => 'first_name',
        'lastname' => 'last_name',
        'dob' => 'dob',
        'gender' => 'gender',
        'pob' => 'pob',
    ]);
```

#### Conditional Behavior

[](#conditional-behavior)

```
CodiceFiscale::make('codice_fiscale')
    ->generator(fn($record) => !$record->exists)
    ->validator(fn($record) => $record->exists)
    ->verifyAgainst(fn($record, $get) => $record->type === 'person'
        ? ['firstName' => 'first_name', 'lastName' => 'last_name', ...]
        : null
    );
```

#### Custom Actions (Advanced)

[](#custom-actions-advanced)

Override the default actions with your own implementations:

```
CodiceFiscale::make('codice_fiscale')
    ->generator()
    ->validator()
    ->usingFinder(MyCustomFinder::class)           // Custom Belfiore code finder
    ->usingCalculator(MyCustomCalculator::class)   // Custom CF calculator
    ->usingValidator(MyCustomValidator::class);    // Custom CF validator
```

Credits
-------

[](#credits)

- **Provincia Autonoma di Bolzano**: German translation data (Pronotel)

License
-------

[](#license)

MIT License - see [LICENSE.md](LICENSE.md) for details.

---

Made with ❤️ by [Kreatif](https://kreatif.it) for the Italian community and Alto Adige / Südtirol region.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance79

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

5

Last Release

111d ago

Major Versions

v1.1.0 → v2.x-dev2026-03-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/c58db6e153a58764dfc820c0a9d33b0a64a26b62eb8c0051912a20edb63b6499?d=identicon)[kreatif](/maintainers/kreatif)

---

Top Contributors

[![mani-repos-link](https://avatars.githubusercontent.com/u/13603818?v=4)](https://github.com/mani-repos-link "mani-repos-link (2 commits)")

---

Tags

laravelmultilingualfilamentfilamentphpgeo-locationcodice fiscalemunicipalitieskreatifitalian-tax-code

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/kreatif-laravel-codice-fiscale/health.svg)

```
[![Health](https://phpackages.com/badges/kreatif-laravel-codice-fiscale/health.svg)](https://phpackages.com/packages/kreatif-laravel-codice-fiscale)
```

###  Alternatives

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

328482.0k25](/packages/codewithdennis-filament-select-tree)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17758.9k2](/packages/stephenjude-filament-jetstream)[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

128173.7k3](/packages/dotswan-filament-map-picker)[mradder/filament-logger

Audit logging, activity tracking, exports, alerts, and dashboards for Filament admin panels.

2310.5k](/packages/mradder-filament-logger)[croustibat/filament-jobs-monitor

Background Jobs monitoring like Horizon for all drivers for FilamentPHP

271298.4k8](/packages/croustibat-filament-jobs-monitor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
