Template directive: switch

The @switch(): conditional directive is part of the conditional loop operator directives. It is being used to check the value of an item.
switch:
Example: switch:
  @php: $apple = 'Apple'; @php;
  
  @switch('fruit'):
   @case('pear'): Pear
   
   @break;
   
   @case('apple'): {{ $apple }} 
   
   @break;
   
   @default: Fruit
  @endswitch;
                
The response returned above will be
   Fruit
                  
Rather than the @php:, we can similarly use the new smart php directive
  {{: $apple = 'Apple'; }} 
  
  @switch('fruit'):
   @case('pear'): Pear
   
   @break;
   
   @case('apple'): {{ $apple }} 
   
   @break;
   
   @default: Fruit
  @endswitch;