Reputation:
How can I check if an attribute exists in an OR
statement, then check in an IF
statement if it is set?
@if($counsellingSession->has_session_begun == 1 || !empty($thread->close_session == 1))
disabled
@elseif($loop->index > 7 && $data->payment_type == 'free')
disabled
@endif
Upvotes: 0
Views: 2066
Reputation: 1341
can you use property_exists
for example:
@if((property_exists($counsellingSession,"has_session_begun") && $counsellingSession->has_session_begun == 1) || (property_exists($thread,"close_session") && $thread->close_session == 1 ) )
disabled
@elseif($loop->index > 7 && $data->payment_type == 'free')
disabled
@endif
Upvotes: 0
Reputation: 9117
use isset
maybe? it will check whether the object is exists or not or null value
@if(isset($thread->close_session) && $thread->close_session == 1)
@endif
Upvotes: 0
Reputation: 4574
try property_exist php function if it exist it will gives you true other wise false
property_exist($thread,'close_session')
read about property_exist
http://php.net/manual/en/function.property-exists.php
Upvotes: 2