All Projects → mvdnbrk → gtin

mvdnbrk / gtin

Licence: MIT license
GTIN / EAN / UPC Validation for Laravel

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to gtin

checkdigit
🔒 An easy-to-use check digit library for data validation
Stars: ✭ 19 (-29.63%)
Mutual labels:  gtin, upc, ean
icecat
Icecat API - Find product description with EAN, UPC or GTIN-13
Stars: ✭ 26 (-3.7%)
Mutual labels:  upc, ean
biip
📦 Biip interprets the data in barcodes.
Stars: ✭ 19 (-29.63%)
Mutual labels:  gtin
Zxing
ZXing ("Zebra Crossing") barcode scanning library for Java, Android
Stars: ✭ 28,795 (+106548.15%)
Mutual labels:  upc
ZiggoNext
Custom component to integrate Arris DCX960 Horizon EOS Settopbox into Home Assistant
Stars: ✭ 33 (+22.22%)
Mutual labels:  upc
images-processing
Project of computational mathematics, image processing, eliminating the noise of an image, reflection of an image and canny filter
Stars: ✭ 23 (-14.81%)
Mutual labels:  upc
inventory
Use a barcode reader to scan the foods in your house and add them to a database. See legacy for zbarcam integration. Master integrates with a USB barcode laser scanner.
Stars: ✭ 32 (+18.52%)
Mutual labels:  upc
homebridge-eosstb
A homebridge plugin for the EOS set-top box as used by Sunrise, Telenet, Ziggo, Magenta, Virgin Media and maybe more in various countries on the Horizon Go (HGO) platform
Stars: ✭ 25 (-7.41%)
Mutual labels:  upc
utk-entrepreneur
Библиотека функций валидации данных юридического лица
Stars: ✭ 26 (-3.7%)
Mutual labels:  ean
Zxing
🎫 Nepxion Zxing is a general code picture generator based on google zxing framework, support QR code and EAN code for file and byte array formats 基于Google Zxing的二维码/条形码创建和扫描组件
Stars: ✭ 26 (-3.7%)
Mutual labels:  ean

GTIN / EAN / UPC Validation for Laravel

PHP version Latest Version on Packagist Software License Tests Code style Total Downloads

Extension for the Laravel validation class.

Installation

You can install the package via composer:

$ composer require mvdnbrk/gtin

Usage

Now you can use the gtin validation to validate a GTIN-8, GTIN-12, GTIN-13 or GTIN-14:

$this->validate($request, [
    'somefield' => 'gtin',
]);

Specifying a custom error message

You may publish the language files with the following artisan command:

php artisan vendor:publish --tag=gtin-lang

Now you can customize the error message in resources/lang/vendor/gtin/{loale}/validation.php.

Another option is to define the error message by adding your message to the custom array in the resources/lang/{locale}/validation.php language file.

'custom' => [
    'somefield' => [
        'gtin' => 'Please enter a valid GTIN!',
    ],
],

Or with a JSON file stored in resources/lang/{locale}.json

{
    "validation.custom.somefield.gtin": "Please enter a valid GTIN!"
}

Or you may pass custom messages as the third argument to the Validator::make method as described in the Laravel documentation.

Helper function

This package exposes a is_gtin() helper function to quickly validate a GTIN.
It will return a boolean whether the given value is a valid GTIN or not:

is_gtin('1300000000000')    // returns true
is_gtin('1234567891234')    // returns false

Migrations

This package contains a helper method to create a GTIN column in your database table:

Schema::table('products', function (Blueprint $table) {
    $table->gtin();
});

If you would like to customize the column name and/or length you may pass these as parameters:

$table->gtin('ean13', 13);

To drop the column you may use the dropGtin method:

Schema::table('products', function (Blueprint $table) {
    $table->dropGtin();
    
    // $table->dropGtin('ean13');
});

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].