I have tried like
foreach ($this->Bay as $k => $obj) {
$obj->{'BayId'} = ($obj->{'BayId'}=='') ? new MongoDB\BSON\ObjectID(); $obj->{'IsDeleted'} = "No"; : new MongoDB\BSON\ObjectID($obj->{'BayId'});
}
if this condition ($obj->{'BayId'}=='') is true, there are two statemenrs which needs to be done.
The above code is throwing error... Please help!!!
The question is not related to parsing error. The question is that if BayId does not contain anything it should be able to overwrite array element with $obj->{'IsDeleted'} = "No"; else it should not do anything
I tried like this also
$obj->{'BayId'} = ($obj->{'BayId'}=='') ? $obj->{'IsDeleted'} = "No";
it does not work