/laravel-sat-catalogs

Provides a artisan command to automatically update SAT catalogs. Use a DB facade to access them.

Primary LanguagePHPMIT LicenseMIT

Gam/laravel-sat-catalogs

Source Code Total Downloads GitHub Workflow Status GitHub GitHub release (latest by date) Packagist PHP Version Support

Simple package providing an Artisan command to update the SAT Catalogs. You can access them through the Catalog Facade.

Installation

You can install the package via composer:

composer require gam/laravel-sat-catalogs

Usage

  1. For lumen applications, register the provider in bootstrap/app.php file, add the following line:

    $app->register(\Gam\LaravelSatCatalogs\CatalogsServiceProvider::class);
    
  2. Set a sqlite3 connection for the driver catalogs. You can change the driver name in config/catalogs.php.
    Example:

    <?php
    /* Custom driver for CFDI Catalogs */
         'catalogs' => [
             'driver' => 'sqlite',
             'url' => '',
             'database' => database_path('catalogs.sqlite3'),
             'prefix' => '',
             'foreign_key_constraints' => true,
         ],
  3. Update the catalogs database

    php artisan catalogs:update --path={$MY_PATH}
  4. Access to the catalogs using Catalog Facade:

    # check if catalog exists
    Catalog::exists('cfdi_40_productos_servicios');
    
    # get a list of catalogs name
    Catalog::availables()
    
    # Get a Query Builder instance
    $ps = Catalog::of('cfdi_40_productos_servicios');
    echo $ps->find('10161511')->texto
    
    # Get the text value of certain row
    $monedaText = Catalog::textOf('cfdi_40_monedas', 'MXN');
    echo $monedaText; # Peso Méxicano

Testing

composer dev:test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email antgam95@gmail.com instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.