PHPackages                             palpalani/laravel-easyrec - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. palpalani/laravel-easyrec

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

palpalani/laravel-easyrec
=========================

A Laravel wrapper for the EasyRec

v2.2.0(1y ago)210.0k[1 PRs](https://github.com/palpalani/laravel-easyrec/pulls)Apache-2.0PHPPHP ^8.2CI passing

Since Aug 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/palpalani/laravel-easyrec)[ Packagist](https://packagist.org/packages/palpalani/laravel-easyrec)[ GitHub Sponsors](https://github.com/palpalani)[ RSS](/packages/palpalani-laravel-easyrec/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (22)Used By (0)

Laravel EasyRec
===============

[](#laravel-easyrec)

[![Latest Version](https://camo.githubusercontent.com/f4e150f84304bc3c85f27e614137e1250392aaf7cd3a57f5f5a7fb906e8082df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f70616c70616c616e692f6c61726176656c2d656173797265632e7376673f7374796c653d666c6174)](https://github.com/palpalani/laravel-easyrec/releases)[![Software License](https://camo.githubusercontent.com/b15dd5b7856b026d8183ded340ff646738284378f4736893fe785a746e482572/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/398d72d66360fb5ab732bb0ee90265c64593b1e370859c988012fccc01fb420a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70616c70616c616e692f6c61726176656c2d656173797265632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/palpalani/laravel-easyrec)[![GitHub Tests Action Status](https://camo.githubusercontent.com/489d10b1c72c75928c1ec4479ed7dc39f8fb74d29068b83c5cd78ad2fa8c41f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6c61726176656c2d656173797265632f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/palpalani/laravel-easyrec/actions?query=workflow%3Arun-tests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a3fd0e6617ddf7872f97b3f129a9cbb31f4d8961cb54673080f1503f4dec4237/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6c61726176656c2d656173797265632f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/palpalani/laravel-easyrec/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/9befd9a3fa217410c11f7d68270bb824671948b254415eded1f1693745926bcb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70616c70616c616e692f6c61726176656c2d656173797265632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/palpalani/laravel-easyrec)

What is EasyRec?
----------------

[](#what-is-easyrec)

EasyRec is an open source recommendation engine system that provides personalized recommendations using a RESTful API.

The recommendation engine server
--------------------------------

[](#the-recommendation-engine-server)

You can use the server and call the associated RESTful API maintained by the easyrec team or download easyrec and call the API on one of your servers.

For additional information, take a look at the [easyrec website](http://easyrec.org).

#### Use EasyRec with the server maintained by the team

[](#use-easyrec-with-the-server-maintained-by-the-team)

This is the ready-to-go solution. You may want to use this if you don't want to configure another server dedicated to easyrec.

- Create an easyrec account:
- Open up your mailbox and activate your account
- Create a new Tenant in your dashboard
- Fill your API key, and your Tenant ID in the configuration file

#### Configure your own easyrec server

[](#configure-your-own-easyrec-server)

Take a look at the [easyrec installation guide](http://easyrec.sourceforge.net/wiki/index.php?title=Installation_Guide).

Installation
------------

[](#installation)

[PHP](https://php.net) 8.0+ and [Composer](https://getcomposer.org) are required.

To get the latest version of Laravel Easyrec, simply add the following line to the require block of your `composer.json`file:

```
"palpalani/laravel-easyrec": "~2.0"

```

You'll then need to run `composer install` or `composer update` to download it and have the autoloader updated.

Fol old version of Laravel you need to register the extension with the blow information. Once Laravel EasyRec is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key.

- `Antoineaugusti\LaravelEasyrec\LaravelEasyrecServiceProvider::class`

You can register the Easyrec facade in the `aliases` key of your `config/app.php` file if you like.

- `'Easyrec' =&gt; Antoineaugusti\\LaravelEasyrec\\Facades\\LaravelEasyrec::class

Configuration
-------------

[](#configuration)

To get started, you'll need to publish all vendor assets:

```
$ php artisan vendor:publish
```

This will create a `config/easyrec.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

Usage
-----

[](#usage)

Actions
-------

[](#actions)

The following variables are common to the actions methods.

##### Required parameters

[](#required-parameters)

- `$itemid`: An item ID to identify an item on your website. Eg: "POST42"
- `$itemdescription`: An item description that is displayed when showing recommendations on your website.
- `$itemurl`: An item URL that links to the item page. Please give an absolute path.
- `$sessionid`: A session ID of a user. If not given, will try to guess with the Session facade `Session::getId()`

##### Optional parameters

[](#optional-parameters)

- `$userid`: A user ID.
- `$itemimageurl`: An optional item image URL that links to an imagine of the item. Please give an absolute path.
- `$actiontime`: An action time parameter that overwrites the current timestamp of the action. The parameter has the format "dd\_MM\_yyyy\_HH\_mm\_ss".
- `$itemtype`: An item type that denotes the type of the item (`IMAGE`, `BOOK` etc.). If not supplied, the default value `ITEM` will be used. **Warning**: before specifying a custom `itemtype` you must add this custom item type by using the web administration panel of Easyrec.

#### Errors

[](#errors)

If an error occurs, an exception `Antoineaugusti\LaravelEasyrec\Exceptions\EasyrecException` will be thrown with one of the following code and message:

- code 299: `Wrong APIKey/Tenant combination!`
- code 301: `Item requires an id!`
- code 303: `Item requires a description!`
- code 304: `Item requires a URL!`
- code 305: `Item requires a valid Rating Value!` (only when calling the `rate` method)
- code 401: `A session id is required!`
- code 912: `Operation failed! itemType XXX not found for tenant YYY`

### View

[](#view)

This action should be raised if a user views an item.

##### Function signature

[](#function-signature)

`Easyrec::view($itemid, $itemdescription, $itemurl, $userid = null, $itemimageurl = null, $actiontime = null, $itemtype = null, $sessionid = null)`

##### Parameters

[](#parameters)

Non-null variables in the function signature are required.

##### Example response

[](#example-response)

The response will be returned as a PHP array.

```
[
	"action": "view",
	"tenantid": "EASYREC_DEMO",
	"userid": "24EH1723322222A3",
	"sessionid": "F3D4E3BE31EE3FA069F5434DB7EC2E34",
	"item": [
	  "id": "42",
	  "itemType": "ITEM",
	  "description": "Fatboy Slim - The Rockafeller Skank",
	  "url": "/item/fatboyslim"
	]
]
```

### Buy

[](#buy)

This action should be raised if a user buys an item.

##### Function signature

[](#function-signature-1)

`Easyrec::buy($itemid, $itemdescription, $itemurl, $userid = null, $itemimageurl = null, $actiontime = null, $itemtype = null, $sessionid = null)`

##### Parameters

[](#parameters-1)

Non-null variables in the function signature are required.

##### Example response

[](#example-response-1)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "buy",
	"userid": "24EH1723322222A3",
	"sessionid": "F3D4E3BE31EE3FA069F5434DB7EC2E34",
	"item": [
	  "id": "42",
	  "type": "ITEM",
	  "description": "Fatboy Slim - The Rockafeller Skank",
	  "url": "/item/fatboyslim"
	]
]
```

### Rate

[](#rate)

This action should be raised if a user rates an item.

##### Function signature

[](#function-signature-2)

`Easyrec::rate($itemid, $ratingvalue, $itemdescription, $itemurl, $userid = null, $itemimageurl = null, $actiontime = null, $itemtype = null, $sessionid = null)`

##### Parameters

[](#parameters-2)

Non-null variables in the function signature are required. The rating value is an additional parameter.

- `$ratingvalue`: the rating value of the item. Must be an integer in the range from 1 to 10.

##### Example response

[](#example-response-2)

The response will be returned as a PHP array.

```
[
	"tenantid": "rate",
	"action": "rate",
	"userid": "24EH1723322222A3",
	"sessionid": "F3D4E3BE31EE3FA069F5434DB7EC2E34",
	"item": [
	  "id": "42",
	  "type": "ITEM",
	  "description": "Fatboy Slim - The Rockafeller Skank",
	  "ratingValue": "10",
	  "url": "/item/fatboyslim"
	]
]
```

### Send a custom action

[](#send-a-custom-action)

This action can be used to send generic user actions.

##### Function signature

[](#function-signature-3)

`sendAction($itemid, $itemdescription, $itemurl, $actiontype, $actionvalue = null, $userid = null, $itemimageurl = null, $actiontime = null, $itemtype = null, $sessionid = null)`

##### Parameters

[](#parameters-3)

Non-null variables in the function signature are required. There are two addition parameters.

- `$actiontype`: A required action type you want to use to send. **You must create the action type in the web interface before you can use it in API calls.**
- `$actionvalue`: If your action type uses action values this parameter is required. It is used to save the action value of your action.

##### Example response

[](#example-response-3)

The response will be returned as a PHP array.

```
[
	"tenantid": "rate",
	"action": "delete",
	"userid": "24EH1723322222A3",
	"sessionid": "F3D4E3BE31EE3FA069F5434DB7EC2E34",
	"item": [
	  "id": "42",
	  "type": "ITEM",
	  "description": "Fatboy Slim - The Rockafeller Skank",
	  "ratingValue": "10",
	  "url": "/item/fatboyslim"
	]
]
```

Recommendations
---------------

[](#recommendations)

The following variables are common to the recommendations methods.

##### Required parameters

[](#required-parameters-1)

- `$itemid`: An item ID to identify an item on your website. Eg: "POST42"

##### Optional parameters

[](#optional-parameters-1)

- `$userid`: A user ID. If this parameter is provided, items viewed by this user are suppressed.
- `$numberOfResults`: determine the number of results returned. Must be an integer in the range from 1 to 15.
- `$itemtype`: An item type that denotes the type of the item (`IMAGE`, `BOOK` etc.). If not supplied, the default value `ITEM` will be used. **Warning**: before specifying a custom `itemtype` you must add this custom item type by using the web administration panel of Easyrec.
- `$requesteditemtype`: A type of an item (e.g. `IMAGE`, `VIDEO`, `BOOK`, etc.) to filter the returned items. If not supplied the default value `ITEM` will be used.
- `$withProfile`: If this parameter is set to `true` the result contains an additional element `profileData` with the item profile. Default value to `false`.

#### Errors

[](#errors-1)

If an error occurs, an exception `Antoineaugusti\LaravelEasyrec\Exceptions\EasyrecException` will be thrown with one of the following code and message:

- code 299: `Wrong APIKey/Tenant combination!`
- code 300: `Item does not exist!`
- code 403: `No Userd Id given!` (only when calling the `recommendationsForUser` method)
- code 912: `Operation failed! itemType XXX not found for tenant YYY`

### Users also viewed

[](#users-also-viewed)

Users who viewed the specified item also viewed the returned items.

##### Function signature

[](#function-signature-4)

`Easyrec::usersAlsoViewed($itemid, $userid = null, $numberOfResults = 10, $itemtype = null, $requesteditemtype = null, $withProfile = false)`

##### Parameters

[](#parameters-4)

Non-null variables in the function signature are required.

##### Example response

[](#example-response-4)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "otherUsersAlsoViewed",
	"user": [
		"id": "24EH1723322222A3"
	],
	"baseitem": [
	  "item": [
		"id": "42",
		"type": "ITEM",
		"description": "Fatboy Slim - The Rockafeller Skank",
		"url": "/item/fatboyslim"
	  ]
	],
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile":[
				"year": "1990"
			]
		],
		"url": "/item/beastieboys"
	  ]
	],
	"listids": [
		43
	]
]
```

##### Retrieving your models

[](#retrieving-your-models)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Users also bought

[](#users-also-bought)

Users who bought the specified item also bought the returned items.

##### Function signature

[](#function-signature-5)

`Easyrec::usersAlsoBought($itemid, $userid = null, $numberOfResults = 10, $itemtype = null, $requesteditemtype = null, $withProfile = false)`

##### Parameters

[](#parameters-5)

Non-null variables in the function signature are required.

##### Example response

[](#example-response-5)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "otherUsersAlsoBought",
	"user": [
		"id": "24EH1723322222A3"
	],
	"baseitem": [
	  "item": [
		"id": "42",
		"type": "ITEM",
		"description": "Fatboy Slim - The Rockafeller Skank",
		"url": "/item/fatboyslim"
	  ]
	],
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile":[
				"year": "1990"
			]
		],
		"url": "/item/beastieboys"
	  ]
	],
	"listids": [
		43
	]
]
```

##### Retrieving your models

[](#retrieving-your-models-1)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Items rated good by other users

[](#items-rated-good-by-other-users)

Users who rated the specified item "good" did the same with items returned by this method.

##### Function signature

[](#function-signature-6)

`Easyrec::ratedGoodByOther($itemid, $userid = null, $numberOfResults = 10, $itemtype = null, $requesteditemtype = null, $withProfile = false)`

##### Parameters

[](#parameters-6)

Non-null variables in the function signature are required.

##### Example response

[](#example-response-6)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "itemsRatedGoodByOtherUsers",
	"user": [
		"id": "24EH1723322222A3"
	],
	"baseitem": [
	  "item": [
		"id": "42",
		"type": "ITEM",
		"description": "Fatboy Slim - The Rockafeller Skank",
		"url": "/item/fatboyslim"
	  ]
	],
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile":[
				"year": "1990"
			]
		],
		"url": "/item/beastieboys"
	  ]
	],
	"listids": [
		43
	]
]
```

##### Retrieving your models

[](#retrieving-your-models-2)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Recommendations for user

[](#recommendations-for-user)

Returns recommendations for a given user ID.

##### Function signature

[](#function-signature-7)

`Easyrec::recommendationsForUser($userid, $numberOfResults = 10, $requesteditemtype = null, $actiontype = "VIEW", $withProfile = false)`

##### Parameters

[](#parameters-7)

Non-null variables in the function signature are required. There is an additional parameter

- `$actiontype`: Allows to define which actions of a user are considered when creating the personalized recommendation. Valid values are: `VIEW`, `RATE`, `BUY`.

##### Example response

[](#example-response-7)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "recommendationsForUser",
	"user": [
		"id": "24EH1723322222A3"
	],
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile":[
				"year": "1990"
			]
		],
		"url": "/item/beastieboys"
	  ]
	],
	"listids": [
		43
	]
]
```

##### Retrieving your models

[](#retrieving-your-models-3)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### History for user

[](#history-for-user)

Returns items which were involved in the latest user actions.

##### Function signature

[](#function-signature-8)

`Easyrec::actionHistoryForUser($userid, $numberOfResults = 10, $requesteditemtype = null, $actiontype = null)`

##### Parameters

[](#parameters-8)

Non-null variables in the function signature are required. There is an additional parameter

- `$actiontype`: Allows to define which actions of a user are considered when creating the personalized recommendation. Valid values are: `VIEW`, `RATE`, `BUY`.

##### Example response

[](#example-response-8)

The response will be returned as a PHP array.

```
[
	'action' => 'actionhistory',
	'recommendeditems' => [
		'item' => [
			0 => [
				'creationDate' => '2014-08-24 12:40:32.0',
				'description' => 'Quote 17982',
				'imageUrl' => [
					'@nil' => 'true'
				],
				'id' => '17982',
				'itemType' => 'QUOTE',
				'profileData' => [
					'@nil' => 'true'
				],
				'url' => 'http://example.com/quotes/17982'
			],
			1 => [
				'creationDate' => '2014-08-24 12:00:59.0',
				'description' => 'Quote 17987',
				'imageUrl' => [
					'@nil' => 'true'
				],
				'id' => '17987',
				'itemType' => 'QUOTE',
				'profileData' => [
					'@nil' => 'true'
				],
				'url' => 'http://example.com/quotes/17982'
			]
		]
	],
	'tenantid' => 'demo',
	'userid' => '27',
	'listids' => [
		0 => 17982,
		1 => 17987,
	]
]
```

##### Retrieving your models

[](#retrieving-your-models-4)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

Rankings
--------

[](#rankings)

The following variables are common to the rankings methods.

##### Optional parameters

[](#optional-parameters-2)

- `$numberOfResults`: determine the number of results returned. Must be an integer in the range from 1 to 50.
- `$requesteditemtype`: An item type that denotes the type of the item (`IMAGE`, `BOOK` etc.). If not supplied, the default value `ITEM` will be used.
- `$timeRange`: An optional parameter to determine the time range. Available values:
    - `DAY`: most viewed items within the last 24 hours
    - `WEEK`: most viewed items within the last week
    - `MONTH`: most viewed items within the last month
    - `ALL` (default): if no value or this value is given, the most viewed items of all time will be shown.
- `$withProfile`: If this parameter is set to `true` the result contains an additional element `profileData` with the item profile. Default value to `false`.

#### Errors

[](#errors-2)

If an error occurs, an exception `Antoineaugusti\LaravelEasyrec\Exceptions\EasyrecException` will be thrown with one of the following code and message:

- code 299: `Wrong APIKey/Tenant combination!`
- code 300: `Item does not exist!`
- code 912: `Operation failed! itemType XXX not found for tenant YYY`

### Most viewed items

[](#most-viewed-items)

Shows items that were viewed most by all users

##### Function signature

[](#function-signature-9)

`Easyrec::mostViewedItems($numberOfResults = 30, $timeRange = 'ALL', $requesteditemtype = null, $withProfile = false)`

##### Example response

[](#example-response-9)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "mostViewedItems",
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile": [
				"year": "1990"
			]
		],
		"url": "/item/beastieboys",
		"imageurl": "/img/covers/beastieboys.jpg",
		"value": "111.0"
	  ]
	],
	"listids": [
		43
	]
]

```

##### Retrieving your models

[](#retrieving-your-models-5)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(\DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Most bought items

[](#most-bought-items)

Shows items that were bought the most.

##### Function signature

[](#function-signature-10)

`Easyrec::mostBoughtItems($numberOfResults = 30, $timeRange = 'ALL', $requesteditemtype = null, $withProfile = false)`

##### Example response

[](#example-response-10)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "mostBoughtItems",
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile": [
				"year": "1990"
			]
		],
		"url": "/item/beastieboys",
		"imageurl": "/img/covers/beastieboys.jpg",
		"value": "111.0"
	  ]
	],
	"listids": [
		43
	]
]

```

##### Retrieving your models

[](#retrieving-your-models-6)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(\DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Most rated items

[](#most-rated-items)

Shows items that were rated the most.

##### Function signature

[](#function-signature-11)

`Easyrec::mostRatedItems($numberOfResults = 30, $timeRange = 'ALL', $requesteditemtype = null, $withProfile = false)`

##### Example response

[](#example-response-11)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "mostRatedItems",
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile": [
				"year": "1990"
			]
		],
		"url": "/item/beastieboys",
		"imageurl": "/img/covers/beastieboys.jpg",
		"value": "111.0"
	  ]
	],
	"listids": [
		43
	]
]

```

##### Retrieving your models

[](#retrieving-your-models-7)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(\DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Best rated items

[](#best-rated-items)

Shows the best rated items. The ranking only includes items that have **an average ranking value greater than 5.5.**

##### Function signature

[](#function-signature-12)

`Easyrec::bestRatedItems($numberOfResults = 30, $timeRange = 'ALL', $requesteditemtype = null, $withProfile = false)`

##### Example response

[](#example-response-12)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "bestRatedItems",
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile": [
				"year": "1990"
			]
		],
		"url": "/item/beastieboys",
		"imageurl": "/img/covers/beastieboys.jpg",
		"value": "111.0"
	  ]
	],
	"listids": [
		43
	]
]

```

##### Retrieving your models

[](#retrieving-your-models-8)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(\DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

### Worst rated items

[](#worst-rated-items)

Shows the worst rated items. The ranking only includes items that have **an average ranking value less than 5.5.**

##### Function signature

[](#function-signature-13)

`Easyrec::worstRatedItems($numberOfResults = 30, $timeRange = 'ALL', $requesteditemtype = null, $withProfile = false)`

##### Example response

[](#example-response-13)

The response will be returned as a PHP array.

```
[
	"tenantid": "EASYREC_DEMO",
	"action": "worstRatedItems",
	"recommendeditems": [
	  "item": [
		"id": "43",
		"type": "ITEM",
		"description": "Beastie Boys - Intergalactic",
		"profileData": [
			"profile": [
				"year": "1990"
			]
		],
		"url": "/item/beastieboys",
		"imageurl": "/img/covers/beastieboys.jpg",
		"value": "111.0"
	  ]
	],
	"listids": [
		43
	]
]

```

##### Retrieving your models

[](#retrieving-your-models-9)

Note that your models can be retrieved using this simple code:

```
YourModel::whereIn('id', $result['listids'])->get();
```

If you want to keep the order of the items, you can use this code if you are using **MySQL**:

```
$ids = $result['listids']:
YourModel::whereIn('id', $ids)
	->orderBy(\DB::raw('FIELD(`id`, '.implode(',', $ids).')'))
	->get();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/palpalani/laravel-easyrec/tags).

Credits
-------

[](#credits)

- [palPalani](https://github.com/palPalani)
- [All Contributors](../../contributors)

License
-------

[](#license)

The Apache License. Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance41

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~221 days

Recently: every ~198 days

Total

18

Last Release

516d ago

Major Versions

v0.5.2 → v1.0-RC12015-02-07

v0.5.4 → v1.02015-04-05

v1.0 → v2.0.02022-10-13

PHP version history (3 changes)v0.1-RC1PHP &gt;=5.4.0

v2.0.0PHP ^8.0

v2.1.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/716695?v=4)[Palaniappan P](/maintainers/palpalani)[@palpalani](https://github.com/palpalani)

---

Top Contributors

[![palpalani](https://avatars.githubusercontent.com/u/716695?v=4)](https://github.com/palpalani "palpalani (70 commits)")[![AntoineAugusti](https://avatars.githubusercontent.com/u/295709?v=4)](https://github.com/AntoineAugusti "AntoineAugusti (63 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

easyreclaravellaravel-5-packagerecommendation-enginelaravelpredictionrecommendationsuggestionspalpalanieasyrecmost viewedmost ratedview togetherbought together

### Embed Badge

![Health badge](/badges/palpalani-laravel-easyrec/health.svg)

```
[![Health](https://phpackages.com/badges/palpalani-laravel-easyrec/health.svg)](https://phpackages.com/packages/palpalani-laravel-easyrec)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[antoineaugusti/laravel-easyrec

A Laravel wrapper for the recommendation system Easyrec

552.3k1](/packages/antoineaugusti-laravel-easyrec)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[bratao/prediction-io

Laravel PredictionIO Client

241.6k](/packages/bratao-prediction-io)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
