Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmyers/laravel-webhooks
A simple webhooks/pubsub package for Laravel.
https://github.com/dmyers/laravel-webhooks
Last synced: 1 day ago
JSON representation
A simple webhooks/pubsub package for Laravel.
- Host: GitHub
- URL: https://github.com/dmyers/laravel-webhooks
- Owner: dmyers
- Created: 2015-03-04T22:15:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-03-04T22:16:20.000Z (over 9 years ago)
- Last Synced: 2023-03-14T08:20:24.248Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 105 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Webhooks Package for Laravel 4
Webhooks is a pubsub/pubsubhubbub system for Laravel 4 applications.
## Installation via Composer
Add this to you composer.json file, in the require object:
```javascript
"dmyers/laravel-webhooks": "dev-master"
```After that, run composer install to install Webhooks.
Add the service provider to `app/config/app.php`, within the `providers` array.
```php
'providers' => array(
// ...
'Dmyers\Webhooks\WebhooksServiceProvider',
)
```Add a class alias to `app/config/app.php`, within the `aliases` array.
```php
'aliases' => array(
// ...
'Webhooks' => 'Dmyers\Webhooks\Webhooks',
)
```Publish the package's model, migration, and view.
```console
php artisan model:publish dmyers/laravel-webhooks
php artisan migration:publish dmyers/laravel-webhooks
```Add the trait to the model you want to act as subscribers on.
```php
use Subscribable;
```Finally, add the trait to the models you want to publish events on.
```php
use Eventable;protected static $eventable = [
'created' => 'object.create',
'updated' => 'object.updated',
'deleted' => 'object.delete',
];protected $eventable_sync = ['id', 'subject'];
```## Usage
First get an instance of an item type (model):
```php
$object = Model::find(1);
```Fetch all the activity:
```php
$object->activity(array(
'id' => $activity_id, // optional
'doer_id' => $doer_id, // optional
'victim_id' => $victim_id, // optional
'item_id' => $item_id, // optional
'item_type' => $item_type, // optional
'feed_type' => $feed_type, // optional
));
```Track an activity event:
```php
$object->addActivity($item_type, $doer_id, $victim_id, $action);
```Update an activity event:
```php
$object->updateActivity($item_type, $doer_id, $victim_id, $action);
```Delete an activity event:
```php
$object->deleteActivity($item_type, $doer_id, $victim_id, $action);
```Display an activity feed:
```php
$object->renderActivityFeed($type, $doer_id, $victim_id);
```Push a feed into another activity feed:
```php
$object->pushActivityFeed($type, $doer_id, $victim_id);
```