Reputation: 7128
I know we can check whether value is empty or not like:
@if(!empty(test))
//print results
@endif
but what if we want to cross check 2 columns for being empty and not being empty?
Sample:
I want check between: $test->one
and $test->two
$test->one
is not empty and $test->two
is empty = x$test->one
and $test->two
both are not empty = yHow do I do that?
My code:
PS:
$test->one
in my sample is equal to $order->options_price
$test->two
in my sample is equal to $order->shipment_price
@if(!empty($order->product_data))
{{ number_format($order->total_price(), 0) }}
@elseif(!empty($order->options_price) && empty($order->shipment_price))
{{ number_format($order->quantity * $order->price + $order->options_price, 0) }}
@elseif(!empty($order->options_price) && !empty($order->shipment_price))
{{ number_format($order->quantity * $order->price + $order->options_price + $order->shipment, 0) }}
@else
{{ number_format($order->quantity * $order->price, 0) }}
@endif
The problem is i cannot get shipment_price
FIXED:
I did have typing mistake in my code.
Upvotes: 0
Views: 634
Reputation:
Laravel also provides the blank
helper method.
Examples from the docs:
blank('');
blank(' ');
blank(null);
blank(collect());
// true
blank(0);
blank(true);
blank(false);
// false
Upvotes: 0
Reputation: 2588
You can do
If $test->one is not empty and $test->two is empty
@if(!empty($test->one) && empty($test->two))
//print results
@endif
If $test->one and $test->two both are not empty
@if(!empty($test->one) && !empty($test->two))
//print results
@endif
Upvotes: 2