title: How can i call just first result from forelse loop in laravel like (array_key_first)?
body: <p><code>@forelse($locations as $key =&gt; $value)</code></p>
  <pre><code>  $result = $query-&gt;get();
  
     $locations = $result-&gt;pluck('name', 'id');
  
      if ($show_all) {
          $locations-&gt;prepend(__('report.all_locations'), '');
      }
  </code></pre>
  <p>instead of all locations, I want a single location/first location to be displayed</p>
  <p>Full View Code</p>
  <pre><code>&lt;div class=&quot;row&quot;&gt;
      &lt;div class=&quot;col-sm-12&quot;&gt;
          @forelse($locations as $key =&gt; $value)
          &lt;div class=&quot;box box-solid&quot;&gt;
              &lt;div class=&quot;box-header&quot;&gt;
                  &lt;h3 class=&quot;box-title&quot;&gt;@lang('sale.location'): {{$value}}&lt;/h3&gt;
              &lt;/div&gt;
              &lt;div class=&quot;box-body&quot;&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;col-sm-12&quot;&gt;
                          &lt;table class=&quot;table table-condensed table-bordered table-th-green text-center table-striped add_opening_stock_table&quot;&gt;
                                  &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;@lang( 'product.product_name' )&lt;/th&gt;
                                      &lt;th&gt;@lang( 'lang_v1.quantity_left' )&lt;/th&gt;
                                      &lt;th&gt;Unit Cost - تكلفة الوحدة)&lt;/th&gt;
                                      @if($enable_expiry == 1 &amp;&amp; $product-&gt;enable_stock == 1)
                                          &lt;th&gt;Exp. Date&lt;/th&gt;
                                      @endif
                                      @if($enable_lot == 1)
                                          &lt;th&gt;@lang( 'lang_v1.lot_number' )&lt;/th&gt;
                                      @endif
                                      &lt;th&gt;Subtotal - المجموع الفرعي&lt;/th&gt;
                                      &lt;th&gt;&amp;nbsp;&lt;/th&gt;
                                  &lt;/tr&gt;
                                  &lt;/thead&gt;
                                  &lt;tbody&gt;
  @php
      $subtotal = 0;
  @endphp
  @foreach($product-&gt;variations as $variation)
      @if(empty($purchases[$key][$variation-&gt;id]))
          @php
              $purchases[$key][$variation-&gt;id][] = ['quantity' =&gt; 0, 
              'purchase_price' =&gt; $variation-&gt;default_purchase_price,
              'purchase_line_id' =&gt; null,
              'lot_number' =&gt; null
              ]
          @endphp
      @endif
  
  @foreach($purchases[$key][$variation-&gt;id] as $sub_key =&gt; $var)
      @php
  
      $purchase_line_id = $var['purchase_line_id'];
  
      $qty = $var['quantity'];
  
      $purcahse_price = $var['purchase_price'];
  
      $row_total = $qty * $purcahse_price;
  
      $subtotal += $row_total;
      $lot_number = $var['lot_number'];
      @endphp
  
  &lt;tr&gt;
      &lt;td&gt;
          {{ $product-&gt;name }} @if( $product-&gt;type == 'variable' ) (&lt;b&gt;{{ $variation-&gt;product_variation-&gt;name }}&lt;/b&gt; : {{ $variation-&gt;name }}) @endif
  
          @if(!empty($purchase_line_id))
              {!! Form::hidden('stocks[' . $key . '][' . $variation-&gt;id . '][' . $sub_key . '][purchase_line_id]', $purchase_line_id); !!}
          @endif
      &lt;/td&gt;
      &lt;td&gt;
          &lt;div class=&quot;input-group&quot;&gt;
            {!! Form::text('stocks[' . $key . '][' . $variation-&gt;id . '][' . $sub_key . '][quantity]', @format_quantity($qty) , ['class' =&gt; 'form-control input-sm input_number purchase_quantity input_quantity', 'required']); !!}
            &lt;span class=&quot;input-group-addon&quot;&gt;
              {{ $product-&gt;unit-&gt;short_name }}
            &lt;/span&gt;
          &lt;/div&gt;
      &lt;/td&gt;
  &lt;td&gt;
      {!! Form::text('stocks[' . $key . '][' . $variation-&gt;id . '][' . $sub_key . '][purchase_price]', @num_format($purcahse_price) , ['class' =&gt; 'form-control input-sm input_number unit_price', 'required']); !!}
  &lt;/td&gt;
  
  @if($enable_expiry == 1 &amp;&amp; $product-&gt;enable_stock == 1)
      &lt;td&gt;
          {!! Form::text('stocks[' . $key . '][' . $variation-&gt;id . '][' . $sub_key . '][exp_date]', !empty($var['exp_date']) ? @format_date($var['exp_date']) : null , ['class' =&gt; 'form-control input-sm os_exp_date', 'readonly']); !!}
      &lt;/td&gt;
  @endif
  
  @if($enable_lot == 1)
      &lt;td&gt;
          {!! Form::text('stocks[' . $key . '][' . $variation-&gt;id . '][' . $sub_key . '][lot_number]', $lot_number , ['class' =&gt; 'form-control input-sm']); !!}
      &lt;/td&gt;
  @endif
      &lt;td&gt;
          &lt;span class=&quot;row_subtotal_before_tax&quot;&gt;{{@num_format($row_total)}}&lt;/span&gt;
      &lt;/td&gt;
      &lt;td&gt;
          @if($loop-&gt;index == 0)
              &lt;button type=&quot;button&quot; class=&quot;btn btn-primary btn-xs add_stock_row&quot; data-sub-key=&quot;{{ count($purchases[$key][$variation-&gt;id])}}&quot; 
                  data-row-html='&lt;tr&gt;
                      &lt;td&gt;
                          {{ $product-&gt;name }} @if( $product-&gt;type == &quot;variable&quot; ) (&lt;b&gt;{{ $variation-&gt;product_variation-&gt;name }}&lt;/b&gt; : {{ $variation-&gt;name }}) @endif
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;div class=&quot;input-group&quot;&gt;
                          &lt;input class=&quot;form-control input-sm input_number purchase_quantity&quot; required=&quot;&quot; name=&quot;stocks[{{$key}}][{{$variation-&gt;id}}][__subkey__][quantity]&quot; type=&quot;text&quot; value=&quot;0&quot;&gt;
                            &lt;span class=&quot;input-group-addon&quot;&gt;
                              {{ $product-&gt;unit-&gt;short_name }}
                            &lt;/span&gt;
                          &lt;/div&gt;
                      &lt;/td&gt;
      &lt;td&gt;
          &lt;input class=&quot;form-control input-sm input_number unit_price&quot; required=&quot;&quot; name=&quot;stocks[{{$key}}][{{$variation-&gt;id}}][__subkey__][purchase_price]&quot; type=&quot;text&quot; value=&quot;{{@num_format($purcahse_price)}}&quot;&gt;
      &lt;/td&gt;
  
      @if($enable_expiry == 1 &amp;&amp; $product-&gt;enable_stock == 1)
      &lt;td&gt;
          &lt;input class=&quot;form-control input-sm os_exp_date&quot; required=&quot;&quot; name=&quot;stocks[{{$key}}][{{$variation-&gt;id}}][__subkey__][exp_date]&quot; type=&quot;text&quot; readonly&gt;
      &lt;/td&gt;
      @endif
  
      @if($enable_lot == 1)
      &lt;td&gt;
          &lt;input class=&quot;form-control input-sm&quot; name=&quot;stocks[{{$key}}][{{$variation-&gt;id}}][__subkey__][lot_number]&quot; type=&quot;text&quot;&gt;
      &lt;/td&gt;
      @endif
  
      &lt;td&gt;
          &lt;span class=&quot;row_subtotal_before_tax&quot;&gt;
              0.00
          &lt;/span&gt;
      &lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;'
      &gt;&lt;i class=&quot;fa fa-plus&quot;&gt;&lt;/i&gt;&lt;/button&gt;
      @else
          &amp;nbsp;
      @endif
              &lt;/td&gt;
              &lt;/tr&gt;
          @endforeach
      @endforeach
                                  &lt;/tbody&gt;
                                  &lt;tfoot&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan=&quot;@if($enable_expiry == 1 &amp;&amp; $product-&gt;enable_stock == 1 &amp;&amp; $enable_lot == 1) 5 @elseif(($enable_expiry == 1 &amp;&amp; $product-&gt;enable_stock == 1) || $enable_lot == 1) @else 3 @endif&quot;&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;strong&gt;Total Amount - المبلغ الإجمالي: &lt;/strong&gt; &lt;span id=&quot;total_subtotal&quot;&gt;{{@num_format($subtotal)}}&lt;/span&gt;
                                      &lt;input type=&quot;hidden&quot; id=&quot;total_subtotal_hidden&quot; value=0&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;/tfoot&gt;
                          &lt;/table&gt;
                          
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt; &lt;!--box end--&gt;
          @empty
              &lt;h3&gt;@lang( 'lang_v1.product_not_assigned_to_any_location' )&lt;/h3&gt;
          @endforelse
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>