{"id":"a9bc624c9c4486c6","repo":"laravel/framework","slug":"property-key-does-not-exist-on-this-collectio","errorCode":null,"errorMessage":"Property [{$key}] does not exist on this collection instance.","messagePattern":"Property \\[(.+?)\\] does not exist on this collection instance\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Collections/Traits/EnumeratesValues.php","lineNumber":1094,"sourceCode":"     * @return void\n     */\n    public static function proxy($method)\n    {\n        static::$proxies[] = $method;\n    }\n\n    /**\n     * Dynamically access collection 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, static::$proxies)) {\n            throw new Exception(\"Property [{$key}] does not exist on this collection instance.\");\n        }\n\n        return new HigherOrderCollectionProxy($this, $key);\n    }\n\n    /**\n     * Results array of items from Collection or Arrayable.\n     *\n     * @param  mixed  $items\n     * @return array<TKey, TValue>\n     */\n    protected function getArrayableItems($items)\n    {\n        return is_null($items) || is_scalar($items) || $items instanceof UnitEnum\n            ? Arr::wrap($items)\n            : Arr::from($items);\n    }\n","sourceCodeStart":1076,"sourceCodeEnd":1112,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Collections/Traits/EnumeratesValues.php#L1076-L1112","documentation":"Thrown by Collection::__get() when accessing an undefined dynamic property. Collections expose a limited set of magic 'proxy' properties (e.g. avg, count, sum via HigherOrderCollectionProxy) listed in static::$proxies; any other property access throws. This prevents silent null returns from typos.","triggerScenarios":"Writing $collection->avrage instead of $collection->avg, or accessing $collection->first_name expecting an item property. Also $collection->total when 'total' isn't a registered proxy.","commonSituations":"Typos in higher-order proxy usage (e.g. $users->each->notify()). Confusing collection property access with model attribute access. IDE auto-complete suggesting a non-existent property.","solutions":["Check the property name against the registered proxies; fix the typo.","Use the method form explicitly: $collection->avg('field') instead of $collection->avg->field.","If you intended item data, call first()/get() on the collection, not property access."],"exampleFix":"// before\n$total = $orders->totl;\n\n// after\n$total = $orders->sum('amount');","handlingStrategy":"validation","validationCode":"$proxies = \\Illuminate\\Support\\Collection::macrosKnownProxies(); // or check static::$proxies\nif (! in_array($prop, \\Illuminate\\Support\\Collection::$proxies, true)) {\n    throw new \\LogicException(\"Unknown property $prop\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $value = $collection->{$prop};\n} catch (\\Exception $e) {\n    $value = null;\n}","preventionTips":["Use the explicit method form ($c->avg('x')) instead of magic proxy properties.","Enable IDE helper / Laravel IDE package for collection proxy auto-complete to avoid typos.","Static-analyze to catch undefined property access."],"tags":["laravel","collections","magic-methods","typo","proxy"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}