squirephp/squire

Call to undefined method Illuminate/Foundation/Application::getFallbackLocale() in Laravel < 7.21

Closed this issue · 1 comments

The Illuminate\Foundation\Application::getFallbackLocale() method does not exist prior to Laravel 7.21. An expression such as

Squire\Models\Country::select(['id', 'name'])->get();

throws the following exception:

PHP Error:  Call to undefined method Illuminate/Foundation/Application::getFallbackLocale() in ... /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 261

Requesting a fix to accommodate Laravel versions prior to 7.12, since there are still a lot of projects out there on v6.x (including mine).

A quick and easy fix would be to grab the fallback locale directly from the config array instead of using the facade:

$appFallbackLocale = App::getFallbackLocale();

Change to

$appFallbackLocale = config('app.fallback_locale');

I'll buy you a virtual beer if you can turn this around quickly (the boss is anxious).

Thanks for your excellent package.

Fixed in v2.1.3 :)