I have condition in my blade template which check if customer is paid from api call. The problem is that doesn't matter if some of if/elseif
conditions is met it's always goes to else
and show what is in there.
@if (is_array($totala['data']['incoming']) || is_object($totala['data']['incoming']))
@foreach($totala['data']['incoming'] as $key => $date)
@endforeach
@if(strpos($date['address'], $address['address']) !== false )
@if($order['price'] == $date['amount'] )
<span>Paid</span>
@elseif($order['price'] < $date['amount'] )
<span>Over Paid</span>
@elseif($order['price'] > $date['amount'] )
<span>Under Paid</span>
@else
@endif
@else
<span>Else block</span>
@endif
@else
<span>Unpaid</span>
@endif
I've made it like this because if I put inner if/else block inside foreach I've got even unwanted results on the page because they are multiple elements inside $totala['data']['vouts']
and foreach loop iterate until there is no more elements..
So why the result always goes in else block?
Note: All data is there and is correct. I've triple checked the data in the json array.
Update: Here is example of the array
Array
(
[status] => success
[data] => Array
(
[id] => id
[incoming] => Array
(
[0] => Array
(
[address] => address1
[amount] => sum1
)
[1] => Array
(
[address] => address2
[amount] => sum2
)
[2] => Array
(
[address] => address3
[amount] => sum3
)
[3] => Array
(
[address] => address4
[amount] => sum4
)
[4] => Array
(
[address] => address5
[amount] => sum5
)
)
)
)
With foreach
I'm looping in array[data][incoming] to search for the address strpos($date['address'], $address['address']) !== false
then when the address is found I want to go trough conditions.
I just realized that I's always goes in else block because they are multiple arrays in [incoming] and there always conditions are not met. Is that correct? If is that how can I fix it?