/**
  * Assembles a single where query based
  * on its operator and returns it.
  *
  * @param array $where
  *
  * @return string|null
  */
 protected function compileWhere(array $where = [])
 {
     // The compile function prefix.
     $prefix = 'compile';
     // Make sure the operator key exists inside the where clause.
     if (array_key_exists(Builder::$whereOperatorKey, $where)) {
         // Get the operator from the where.
         $operator = $where[Builder::$whereOperatorKey];
         // Get the name of the operator.
         $name = array_search($operator, Operator::all());
         if ($name !== false) {
             // If the name was found we'll camel case it
             // to run it through the compile method.
             $method = $prefix . ucfirst($name);
             // Make sure the compile method exists for the operator.
             if (method_exists($this, $method)) {
                 return $this->{$method}($where[Builder::$whereFieldKey], $where[Builder::$whereValueKey]);
             }
         }
     }
     return;
 }
Esempio n. 2
0
 public function listAction()
 {
     $operators = Operator::all();
     $this->view->setVar('operators', $operators);
 }