{"id":19319001,"url":"https://github.com/zaxwebs/ex-lw-updatedhook","last_synced_at":"2025-09-11T02:40:48.717Z","repository":{"id":101629679,"uuid":"340085047","full_name":"zaxwebs/ex-lw-updatedHook","owner":"zaxwebs","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-18T15:10:48.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T06:33:04.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaxwebs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-18T15:01:29.000Z","updated_at":"2021-02-18T15:10:50.000Z","dependencies_parsed_at":"2023-06-06T23:00:31.884Z","dependency_job_id":null,"html_url":"https://github.com/zaxwebs/ex-lw-updatedHook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zaxwebs/ex-lw-updatedHook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaxwebs%2Fex-lw-updatedHook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaxwebs%2Fex-lw-updatedHook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaxwebs%2Fex-lw-updatedHook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaxwebs%2Fex-lw-updatedHook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaxwebs","download_url":"https://codeload.github.com/zaxwebs/ex-lw-updatedHook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaxwebs%2Fex-lw-updatedHook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274568713,"owners_count":25309283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:20:37.327Z","updated_at":"2025-09-11T02:40:48.700Z","avatar_url":"https://github.com/zaxwebs.png","language":"PHP","funding_links":["https://patreon.com/taylorotwell"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://laravel.com\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg\" width=\"400\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/laravel/framework\"\u003e\u003cimg src=\"https://travis-ci.org/laravel/framework.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel/framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/laravel/framework\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel/framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/laravel/framework\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel/framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/laravel/framework\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nI recently got started with Livewire and I'm in absolute awe. It makes creating dynamic interfaces so easy while sticking to the familiarity of Laravel. Okay, enough praising for now.\n\nI'm writing this article to highlight a slight niche and currently undocumented feature.\n\n# The Scenario\nOkay, consider this: In your component class, you have an array:\n```php\npublic $products= [\n        [\n            'id' =\u003e '2535230536',\n            'rate' =\u003e '32424',\n        ],\n        [\n            'id' =\u003e '3960700133',\n            'rate' =\u003e '24523',\n        ],\n        [\n            'id' =\u003e '0524548004',\n            'rate' =\u003e '45574',\n        ],\n    ];\n```\nAnd in the view, you have the 'id's \u0026 'rates's bound to inputs.\n```html\n@foreach($products as $index =\u003e $product)\n\u003cdiv  wire:key=\"products-{{ $index }}\"\u003e\n\t\u003cdiv\u003e\n\t\t\u003clabel\u003eID\u003c/label\u003e\n\t\u003cinput type=\"text\" wire:model=\"products.{{ $index }}.id\"\u003e\n\t\u003c/div\u003e\n\t\u003cdiv\u003e\n\t\t\u003clabel\u003eRate\u003c/label\u003e\n\t\t\u003cinput type=\"text\" wire:model=\"products.{{ $index }}.rate\"\u003e\n\t\u003c/div\u003e\n\u003c/div\u003e\n```\nNow, what if you want to hook a task any time a product ID is updated? Something like if ID was updated, update the rate accordingly.\n\n# The Concerns\nLet's see... Doing something like:\n```php\npublic function updatedRooms() {\n        \n}\n```\nThis runs every time `$rooms` gets updated. But we want to run as task when any 'id' gets updated not `$rooms` as a whole.\n```php\npublic function updatedRooms0Id() {\n        \n}\n```\nThis runs every time `$rooms[0]['id']` gets updated. Which works for the first 'id' but... having to repeat the function (`updatedRooms0Id`, `updatedRooms1Id`...) for every index isn't really DRY.\n\n# The Solution\nWouldn't it be great if only there was a way to access the index? Turns out there is...\n```php\npublic function updatedRooms($value, $key) {\n        \n}\n```\n`$key` in our example would return `0.id` if the first ID was updated. The first part before the dot is our index. Which is what we needed! You can now operate on the key to setup tasks you'd like to with something like and if statement.\n\n# That's All Folks!\nAnd before I go, I'd like to thank [Josh Hanley](https://github.com/joshhanley) for helping me with this solution. I hope this article helps many more out there.\n\n## About Laravel\n\nLaravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:\n\n- [Simple, fast routing engine](https://laravel.com/docs/routing).\n- [Powerful dependency injection container](https://laravel.com/docs/container).\n- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.\n- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).\n- Database agnostic [schema migrations](https://laravel.com/docs/migrations).\n- [Robust background job processing](https://laravel.com/docs/queues).\n- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).\n\nLaravel is accessible, powerful, and provides tools required for large, robust applications.\n\n## Learning Laravel\n\nLaravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.\n\nIf you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.\n\n## Laravel Sponsors\n\nWe would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).\n\n### Premium Partners\n\n- **[Vehikl](https://vehikl.com/)**\n- **[Tighten Co.](https://tighten.co)**\n- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**\n- **[64 Robots](https://64robots.com)**\n- **[Cubet Techno Labs](https://cubettech.com)**\n- **[Cyber-Duck](https://cyber-duck.co.uk)**\n- **[Many](https://www.many.co.uk)**\n- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**\n- **[DevSquad](https://devsquad.com)**\n- **[Curotec](https://www.curotec.com/)**\n- **[OP.GG](https://op.gg)**\n\n## Contributing\n\nThank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).\n\n## Code of Conduct\n\nIn order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).\n\n## Security Vulnerabilities\n\nIf you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.\n\n## License\n\nThe Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaxwebs%2Fex-lw-updatedhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaxwebs%2Fex-lw-updatedhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaxwebs%2Fex-lw-updatedhook/lists"}