根据 laravel 中的条件显示部分
Display a section according Condition in laravel
我有两个来自控制器的 return 变量要在 Laravel.
中查看
return view ('home', compact('books','count'));
现在我要显示一节('content')@如果条件为真
在我的 home.blade.php 中。我该怎么做。现在 section('content') 将显示 @if condition is false
@if (!empty($books))
@section('content')
@endif
您可以使用 @else
、@elseif
、@unless
这是一个例子
@if (count($books))
section('content')
@else
@section('your other section')
@endif
希望对您有所帮助
我有两个来自控制器的 return 变量要在 Laravel.
中查看return view ('home', compact('books','count'));
现在我要显示一节('content')@如果条件为真 在我的 home.blade.php 中。我该怎么做。现在 section('content') 将显示 @if condition is false
@if (!empty($books))
@section('content')
@endif
您可以使用 @else
、@elseif
、@unless
这是一个例子
@if (count($books))
section('content')
@else
@section('your other section')
@endif
希望对您有所帮助