如果变量为空,则禁用按钮

So I have this forelse that displays all the variants, now what I want to happen is that, if there is no variant. the submit button will be disabled.

                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th class="col-sm-5">Name</th>
                                    <th class="col-sm-1">Default?</th>
                                    <th class="col-sm-2 text-right">Retail Price</th>
                                    <th class="col-sm-2 text-right">Quantity</th>
                                    <th class="col-sm-2"></th>
                                </tr>
                            </thead>
                            <tbody>
                            @forelse ($product->variants as $index => $variant)
                                <tr>
                                    <td>{{ $variant->name }}</td>
                                    <td>{{ $variant->is_default ? 'Yes' : 'No' }}</td>
                                    <td class="text-right">{{ number_format($variant->retail_price, 2) }} {{ $variant->price_currency }}</td>
                                    <td class="text-right">{{ number_format($variant->quantity, 0) }}</td>
                                    <td><a href="{{ route('developer.variants.edit', [$store->slug, $product, $variant]) }}" class="btn btn-xs btn-default pull-right">Edit</a></td>
                                </tr>
                            @empty
                                <tr>
                                    <td colspan="5">No variants found</td>
                                    <?php $varbutton = 'disabled';?>
                                </tr>
                            @endforelse
                            </tbody>
                        </table>

here is the button

<div class="panel-footer">
  <button class="btn btn-default" type="submit"<?php $varbutton; ?>>Update Store</button>
</div>

Is it possible using php and html in the blade alone or do I have to do it in the controller?

You should be using blade in your button:

<div class="panel-footer">
  <button class="btn btn-default" type="submit" {{ $varbutton }}>Update Store</button>
</div>

Also please note that there needs to be a space after "submit".

Or, if you don't want that space when the button is not disabled, use:

<?php $varbutton = ' disabled';?>
<div class="panel-footer">
  <button class="btn btn-default" type="submit"{{ $varbutton }}>Update Store</button>
</div>