Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zacksleo/yii2-recently-viewed-behavior
yii2 recently viewed behavior
https://github.com/zacksleo/yii2-recently-viewed-behavior
yii2 yii2-behaviors yii2-extension
Last synced: 21 days ago
JSON representation
yii2 recently viewed behavior
- Host: GitHub
- URL: https://github.com/zacksleo/yii2-recently-viewed-behavior
- Owner: zacksleo
- License: mit
- Created: 2017-08-27T03:35:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-06T06:01:47.000Z (over 6 years ago)
- Last Synced: 2024-10-07T17:01:11.402Z (about 1 month ago)
- Topics: yii2, yii2-behaviors, yii2-extension
- Language: PHP
- Size: 18.6 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-recently-viewed-behavior
[![StyleCI](https://styleci.io/repos/101527643/shield?branch=master)](https://styleci.io/repos/101527643)
[![Build Status](https://travis-ci.org/zacksleo/yii2-recently-viewed-behavior.svg?branch=master)](https://travis-ci.org/zacksleo/yii2-recently-viewed-behavior)
[![Code Climate](https://img.shields.io/codeclimate/github/zacksleo/yii2-recently-viewed-behavior.svg)]()
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/zacksleo/yii2-recently-viewed-behavior/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/zacksleo/yii2-recently-viewed-behavior/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/zacksleo/yii2-recently-viewed-behavior/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/zacksleo/yii2-recently-viewed-behavior/?branch=master)## Quick Start
### Install
```bash
composer install zacksleo/yii2-recently-viewed-behavior
```### Usage
```php
use yii\web\Controller;
use zacksleo\yii2\behaviors\RecentlyViewedBehavior;class DefaultController extends Controller
{public function behaviors()
{
return [
'recentlyViewed' => [
'class' => RecentlyViewedBehavior::className(),
'limit' => 5, // Limit the number of recently viewed items stored. 0 = no limit.
],
];
}
public function actionView($id)
{
// set recently models
$model = $this->findModel($id);
$this->setRecentlyViewed(get_class($model), $id);
// get recently models
$this->getRecentlyViewed(get_class($model));
}```