定制 dmyers/laravel-activity 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dmyers/laravel-activity

Composer 安装命令:

composer require dmyers/laravel-activity

包简介

A simple activity feed package for Laravel 4.

README 文档

README

Activity is a activity/news feed system for Laravel 4 applications.

Installation via Composer

Add this to you composer.json file, in the require object:

"dmyers/laravel-activity": "dev-master"

After that, run composer install to install Activity.

Add the service provider to app/config/app.php, within the providers array.

'providers' => array(
    // ...
    'Dmyers\Activity\ActivityServiceProvider',
)

Add a class alias to app/config/app.php, within the aliases array.

'aliases' => array(
    // ...
    'Activity' => 'Dmyers\Activity\Activity',
)

Publish the package's model, migration, and view.

php artisan model:publish dmyers/laravel-activity
php artisan migration:publish dmyers/laravel-activity
php artisan view:publish dmyers/laravel-activity

Finally, add the trait to the models you want to track activity on.

use ActivityTrait;

protected $activity_item_field = 'id';

protected $activity_doer_field = 'user_id';

protected $activity_events = array('created', 'updated', 'deleted');

protected $activity_feed_type = 'user';

Usage

First get an instance of an item type (model):

$object = Model::find(1);

Fetch all the activity:

$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:

$object->addActivity($item_type, $doer_id, $victim_id, $action);

Update an activity event:

$object->updateActivity($item_type, $doer_id, $victim_id, $action);

Delete an activity event:

$object->deleteActivity($item_type, $doer_id, $victim_id, $action);

Display an activity feed:

$object->renderActivityFeed($type, $doer_id, $victim_id);

Push a feed into another activity feed:

$object->pushActivityFeed($type, $doer_id, $victim_id);

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-29