I have a basic if/else statement is Laravel.
$model = MyModel::where('row', 'abc123')->first();
// Returns 3 statuses - connected, inactive, disconnected
$status = getStatus();
if ($status === 'connected') {
if (!$model->is_active) {
$model->timed_at = now();
}
$model->is_active = true;
}
else {
if ($model->is_active) {
$model->last_timed_at = $model->updated_at;
}
$model->is_active = false;
}
$model->save();
NOTE: This function is called repeatedly at an interval of 10 seconds.
The ELSE functionality works flawlessly outside the ELSE statement.
But the moment it's in the ELSE, it doesn't run at all.
I have proven that it does reach the ELSE by adding an echo which works fine.
Another odd thing, when I place the ELSE in the IF side, it works perfectly fine.