5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel6.x移行でハマった話

Last updated at Posted at 2019-11-29

Illuminate\Support\Facades\LangのLang::getFromJsonが6.x移行で使えなくなってて

local.ERROR: Method Illuminate\Translation\Translator::getFromJson does not exist.
などというエラーに見舞われてしまった
ググっても

php artisan view:clear
php artisan view:cache

しろとしかヒットせず
自作のメールテンプレートで多言語処理を実装していた場合、これでは解決できない

Laravel5とLaravel6にて
Illuminate\Translation\Translator.phpを見比べてみると確かにgetFromJsonメソッドがなくなっており
getFromJsonを利用する側のIlluminate/Auth/Notifications/VerifyEmail.phpのtoMail()メソッド内の処理を見比べてみると

-Lang::getFromJson()
+Lang::get()

と置き換わっており
このメソッド書き換えを行うと6.x(6.2環境で確認)で正しく動作した

関連
Laravelで多言語対応いろいろ
https://qiita.com/shikigamix/items/d92ec72b4418f31c356d

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?