laravel/framework · error · Exception

Property [ ] does not exist on the Eloquent builder…

Error message

Property [{$key}] does not exist on the Eloquent builder instance.

What it means

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.

Solutions

  1. Call the method explicitly with parentheses: $query->getMethod() rather than $query->method.
  2. For relations/attributes, access them on the resolved model(s): $model->relation, not $query->relation.
  3. To inspect internal query state (wheres, bindings, columns), use ->toBase()->wheres etc., or ->getQuery()-><prop>, since those live on the underlying Query\Builder.
  4. If you need 'from', it is already in propertyPassthru and will pass through correctly.

Example fix

// before
$from = User::where('active', 1)->frm;     // typo, throws
$relations = User::where('active', 1)->posts; // relation accessed on builder

// after
$from = User::where('active', 1)->from;       // in propertyPassthru
$posts = User::where('active', 1)->first()->posts;
Defensive patterns

Strategy: type-guard

Validate before calling

$allowed = ['orWhere', 'whereNot', 'orWhereNot', 'from'];
if (in_array($key, $allowed, true)) {
    $value = $builder->{$key};
} else {
    throw new \LogicException("Property [{$key}] is not accessible on the builder; use a method.");
}

Type guard

function isAccessibleBuilderProperty(string $key): bool {
    return in_array($key, ['orWhere', 'whereNot', 'orWhereNot', 'from'], true);
}

Try / catch

try {
    $value = $builder->{$key};
} catch (\Exception $e) {
    $value = $builder->getModel()->{$key}; // fall back to model property/relation
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/8ac763d7d5727cbd. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Database/Eloquent/Builder.php:2242

    /**
     * Dynamically access builder proxies.
     *
     * @param  string  $key
     * @return mixed
     *
     * @throws \Exception
     */
    public function __get($key)
    {
        if (in_array($key, ['orWhere', 'whereNot', 'orWhereNot'])) {
            return new HigherOrderBuilderProxy($this, $key);
        }

        if (in_array($key, $this->propertyPassthru)) {
            return $this->toBase()->{$key};
        }

        throw new Exception("Property [{$key}] does not exist on the Eloquent builder instance.");
    }

    /**
     * Dynamically handle calls into the query instance.
     *
     * @param  string  $method
     * @param  array  $parameters
     * @return mixed
     */
    public function __call($method, $parameters)
    {
        if ($method === 'macro') {
            $this->localMacros[$parameters[0]] = $parameters[1];

            return;
        }

        if ($this->hasMacro($method)) {

View on GitHub (pinned to e0f6eb3518)