LoginSignup
4
3

More than 5 years have passed since last update.

Laravel5.8の準備:ヘルパー

Posted at

Laravel5.8では一部のヘルパー(array_*str_**_case等)が非推奨になる。たぶん5.9で削除。
すでに大量に使ってるなら修正せずにこのヘルパーパッケージを使ってそのまま使い続ければいい。
https://github.com/laravel/helpers
自分のプロジェクト内は修正しても結局外部のパッケージが使ってて必要になると予想してる。
パッケージ作ってる人は対応しよう。

Bladeでは

この提案した人Blade書いてないのかよってほどにBladeでは不便になる。
https://github.com/laravel/framework/pull/26898

ヘルパーならこれだけなのに

{{ str_limit($content, 140) }}

フルで書くとこれ…。

{{ \Illuminate\Support\Str::limit($content, 140) }}

ひどいけど良い解決方法があった。

config/app.phpのaliasesに追加。

'aliases' => [
    ...

    'Str'          => \Illuminate\Support\Str::class,
    'Arr'          => \Illuminate\Support\Arr::class,
],

こう書けるので短くなった。

{{ Str::limit($content, 140) }}

ヘルパー使わないならこれ。

4
3
1

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
4
3