jeudi 1 septembre 2016

Laravel if statement with other variable value

I try to get data from a model, but the value of the column name from the data model is in another variable. Here's a little preview what I try to achieve:

switch($device->target_objectclass_id) {
    case 10:
        $handler = Servers::findOrFail($device->target_object_id);
    default:
        break;
}

if($handler->($condition->column) ($condition->condition) ($condition->value)) {
    //process the other data it it's true
}

Example of what should be displayed:

if($handler->status == 1) { 
    //handle data 
}

The reason behide this is a little bit complicated. The user's need to create triggers which will be executed.


For example:

  • check table where column condition value
  • check servers where status == 1

Hope someone has an answer if you can understand my problem...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire