{"id":16294154,"url":"https://github.com/sarfraznawaz2005/eventable","last_synced_at":"2025-04-05T17:31:50.883Z","repository":{"id":62540356,"uuid":"103785361","full_name":"sarfraznawaz2005/eventable","owner":"sarfraznawaz2005","description":"Laravel package to easily add event listening capabilities to any model on Create/Update/Delete operations.","archived":false,"fork":false,"pushed_at":"2017-09-16T21:59:07.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T07:41:36.351Z","etag":null,"topics":["eloquent","events","laravel","laravel-5-package","model","php"],"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/sarfraznawaz2005.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}},"created_at":"2017-09-16T21:37:41.000Z","updated_at":"2021-01-20T12:35:06.000Z","dependencies_parsed_at":"2022-11-02T15:46:17.714Z","dependency_job_id":null,"html_url":"https://github.com/sarfraznawaz2005/eventable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Feventable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Feventable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Feventable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Feventable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sarfraznawaz2005","download_url":"https://codeload.github.com/sarfraznawaz2005/eventable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247374688,"owners_count":20928871,"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","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":["eloquent","events","laravel","laravel-5-package","model","php"],"created_at":"2024-10-10T20:14:21.636Z","updated_at":"2025-04-05T17:31:50.597Z","avatar_url":"https://github.com/sarfraznawaz2005.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Eventable\n\n[![laravel 5.1](https://img.shields.io/badge/Laravel-5.1-brightgreen.svg?style=flat-square)](http://laravel.com)\n[![laravel 5.2](https://img.shields.io/badge/Laravel-5.2-brightgreen.svg?style=flat-square)](http://laravel.com)\n[![laravel 5.3](https://img.shields.io/badge/Laravel-5.3-brightgreen.svg?style=flat-square)](http://laravel.com)\n[![laravel 5.4](https://img.shields.io/badge/Laravel-5.4-brightgreen.svg?style=flat-square)](http://laravel.com)\n[![downloads](https://poser.pugx.org/sarfraznawaz2005/eventable/downloads)](https://packagist.org/packages/sarfraznawaz2005/eventable)\n\n## Introduction ##\n\nSimple Laravel 5 package to easily add event listening capabilities to any model on Create/Update/Delete operations.\n\n## Requirements ##\n\n - PHP \u003e= 5.6\n - Laravel 5\n\n## Installation ##\n\nInstall via composer\n\n```\ncomposer require sarfraznawaz2005/eventable\n```\n\nThat's it!\n\n## Usage ##\n\nSuppose you have a model called `Task` and you want to be able to do something when it's created/updated or deleted. To do that, just use the `Eventable` trait like so:\n\n```\n...\nuse Sarfraznawaz2005\\Eventable\\Eventable;\n\nclass Task extends Model\n{\n    use Eventable;\n    \n    ...\n}\n```\n\nNow somewhere in your app, you can listen to events and do whatever you want:\n\n```\nEvent::listen('task.created', function ($task) {\n    // do something when task is created. In this case, just log it.\n    Log::info('Task with id ' . $task-\u003eid . ' was created.');\n});\n\nEvent::listen('task.updated', function ($task) {\n    // do something when task is updated. In this case, just log it.\n    Log::info('Task with id ' . $task-\u003eid . ' was updated.');\n});\n\nEvent::listen('task.deleted', function ($task) {\n    // do something when task is deleted. In this case, just log it.\n    Log::info('Task with id ' . $task-\u003eid . ' was deleted.');\n});\n```\n\n**Note:** Make sure your put event listening logic BEFORE saving/updating/deletng model logic.\n\n## License ##\n\nThis code is published under the [MIT License](http://opensource.org/licenses/MIT).\nThis means you can do almost anything with it, as long as the copyright notice and the accompanying license file is left intact.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarfraznawaz2005%2Feventable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsarfraznawaz2005%2Feventable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarfraznawaz2005%2Feventable/lists"}