diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index eb8efe5837e8..f0ba8eabeb17 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -1138,4 +1138,15 @@ protected static function getMutatorMethods($class) return $matches[1]; } + + /** + * Checks if a specific attribute exists. + * + * @param string $key + * @return bool + */ + public function hasAttribute($key) + { + return array_key_exists($key, $this->attributesToArray()); + } }