T
T
Taras Parashchuk2020-11-24 15:49:01
Laravel
Taras Parashchuk, 2020-11-24 15:49:01

How to check variable value in laravel 7?

If the array is not empty then it works, if it is empty it gives an error.

@if (count($products))
    @foreach ($products as $product)
        <tr><td>  {{ $product->kod }}</td><td>  {{ $product->price }}</td><  <td> {{ $product->kod }}<td></td></tr>
    @endforeach
        {{ $products->links() }}
@else
    I don't have any records!
@endif

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sarvarov, 2020-11-24
@taras1978

@if(! empty($products))
    @foreach ($products as $product)
        {{ $product->kod }} {{ $product->price }}< {{ $product->kod }}
    @endforeach    

    {{ $products->links() }}
@else
    I don't have any records!
@endif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question