/** * Handle dynamic method calls. * * @param string $method * @param array $arguments * * @return Query|Field */ public function __call($method, $arguments) { static $whitelist = array('select', 'insert', 'update', 'delete', 'values', 'bindings', 'where', 'count', 'min', 'max', 'sum', 'avg', 'first', 'all', 'column'); // Act as proxy for Database\Query methods if (in_array($method, $whitelist)) { return call_user_func_array(array($this->query(), $method), $arguments); } // Call the attribute getter/setter $attribute = Str::snakecase($method); if (empty($arguments)) { return $this->get($attribute); } else { array_unshift($arguments, $attribute); return call_user_func_array(array($this, 'set'), $arguments); } }
/** * Register an error during the validation test. * * @param string $attribute Name of the field. * @param string $rule Rule that failed. */ protected function addMessage($attribute, $rule) { $a = Str::snakecase($attribute); $r = Str::snakecase($rule); $message = a::get($this->messages, "{$a}.{$r}", a::get($this->messages, $rule)); if (empty($message)) { $message = l("comments.validator.{$a}.{$r}"); } if (empty($message)) { $message = l("comments.validator.{$r}"); } if (empty($message)) { $message = l('comments.validator.fallback', 'Invalid value for {key}'); } $this->errors->add($attribute, $message); }