{"record":{"id":"8ac763d7d5727cbd","repo":"laravel/framework","slug":"property-key-does-not-exist-on-the-eloquent-b","errorCode":null,"errorMessage":"Property [{$key}] does not exist on the Eloquent builder instance.","messagePattern":"Property \\[(.+?)\\] does not exist on the Eloquent builder instance\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Eloquent/Builder.php","lineNumber":2242,"sourceCode":"    /**\n     * Dynamically access builder proxies.\n     *\n     * @param  string  $key\n     * @return mixed\n     *\n     * @throws \\Exception\n     */\n    public function __get($key)\n    {\n        if (in_array($key, ['orWhere', 'whereNot', 'orWhereNot'])) {\n            return new HigherOrderBuilderProxy($this, $key);\n        }\n\n        if (in_array($key, $this->propertyPassthru)) {\n            return $this->toBase()->{$key};\n        }\n\n        throw new Exception(\"Property [{$key}] does not exist on the Eloquent builder instance.\");\n    }\n\n    /**\n     * Dynamically handle calls into the query instance.\n     *\n     * @param  string  $method\n     * @param  array  $parameters\n     * @return mixed\n     */\n    public function __call($method, $parameters)\n    {\n        if ($method === 'macro') {\n            $this->localMacros[$parameters[0]] = $parameters[1];\n\n            return;\n        }\n\n        if ($this->hasMacro($method)) {","sourceCodeStart":2224,"sourceCodeEnd":2260,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Eloquent/Builder.php#L2224-L2260","documentation":"Thrown by Eloquent\\Builder::__get() when a dynamic property access does not match the small set of allowed properties. The magic getter handles only the higher-order proxies (orWhere, whereNot, orWhereNot) and the propertyPassthru list (currently just 'from'); any other property access falls through to the exception. The intent is to surface typos and misused property access early, since most builder interaction is via methods, not properties.","triggerScenarios":"Accessing $query->someProperty that is not 'orWhere'/'whereNot'/'orWhereNot' and not 'from'; e.g. $users = User::where('active', 1)->users; or attempting to read a relation/column as a property on the builder instead of the model.","commonSituations":"Treating the Builder like the Model (relations/attributes live on Model, not Builder); typo where a method call was written without parentheses; expecting a query-state property (like 'wheres' or 'bindings') that is not in propertyPassthru.","solutions":["Call the method explicitly with parentheses: $query->getMethod() rather than $query->method.","For relations/attributes, access them on the resolved model(s): $model->relation, not $query->relation.","To inspect internal query state (wheres, bindings, columns), use ->toBase()->wheres etc., or ->getQuery()-><prop>, since those live on the underlying Query\\Builder.","If you need 'from', it is already in propertyPassthru and will pass through correctly."],"exampleFix":"// before\n$from = User::where('active', 1)->frm;     // typo, throws\n$relations = User::where('active', 1)->posts; // relation accessed on builder\n\n// after\n$from = User::where('active', 1)->from;       // in propertyPassthru\n$posts = User::where('active', 1)->first()->posts;","handlingStrategy":"type-guard","validationCode":"$allowed = ['orWhere', 'whereNot', 'orWhereNot', 'from'];\nif (in_array($key, $allowed, true)) {\n    $value = $builder->{$key};\n} else {\n    throw new \\LogicException(\"Property [{$key}] is not accessible on the builder; use a method.\");\n}","typeGuard":"function isAccessibleBuilderProperty(string $key): bool {\n    return in_array($key, ['orWhere', 'whereNot', 'orWhereNot', 'from'], true);\n}","tryCatchPattern":"try {\n    $value = $builder->{$key};\n} catch (\\Exception $e) {\n    $value = $builder->getModel()->{$key}; // fall back to model property/relation\n}","preventionTips":["Call builder methods with parentheses rather than using property access.","Access relations/attributes on the resolved Model, not the Builder.","For internal query state, use ->toBase()->{prop} or ->getQuery()->{prop}."],"tags":["database","eloquent","builder","magic-methods","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}