LoginSignup
1

More than 3 years have passed since last update.

LaravelのincludeWhenはfalseでも右辺の評価が行われてしまう。

Posted at

includeWhenの条件式が false でも右辺が評価されてしまう

そのため isset で変数があるかどうかチェックしても、右辺が評価されてしまい
Undefined variable: user と表示されてしまう。

blade.php
@includeWhen(isset($user), 'tags.google', ['user' => $user])

諦めてif文で書きましょう

blade.php
@if (isset($user))
  @include('tags.google', ['user' => $user])
@endif

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
1