robertogallea / laravel-codicefiscale

Codice fiscale validation for php/laravel
MIT License
42 stars 16 forks source link

Prevent code to break in production environment #66

Closed fabio-ivona closed 2 months ago

fabio-ivona commented 2 months ago

Hi @robertogallea

this commit (https://github.com/robertogallea/laravel-codicefiscale/commit/73dabd5b9dc6a4aad10c05f47df6021720fb6fa7) broke our application in production env, because fake() helper is not defined

I've just added the same check Laravel applies in helpers.php:462 before defining fake():

if (! function_exists('fake') && class_exists(\Faker\Factory::class)) {
    /**
     * Get a faker instance.
     *
     * @param  string|null  $locale
     * @return \Faker\Generator
     */
    function fake($locale = null)
    {
        if (app()->bound('config')) {
            $locale ??= app('config')->get('app.faker_locale');
        }

        $locale ??= 'en_US';

        $abstract = \Faker\Generator::class.':'.$locale;

        if (! app()->bound($abstract)) {
            app()->singleton($abstract, fn () => \Faker\Factory::create($locale));
        }

        return app()->make($abstract);
    }
}
eleftrik commented 2 months ago

@robertogallea Since this PR has been merged to master, are you planning to tag a new release 2.0.1?

Thank you

robertogallea commented 2 months ago

We are already on tag v2.0.2

eleftrik commented 2 months ago

@robertogallea My fault. I didn't look at tags. Only the releases, so I have been misled.

robertogallea commented 2 months ago

I also added a release for tag v2.0.2 just now ;)