mmedia/laravel-collaborative-filtering
最新稳定版本:1.0.2
Composer 安装命令:
composer require mmedia/laravel-collaborative-filtering
包简介
Simple trait to add collaborative filtering to your models
README 文档
README
Get related models for the current model. Commonly used for "similar products" sections.
Installation
You can install the package via composer:
composer require mmedia/laravel-collaborative-filtering
Usage
Imagine you have a model called Product, and each product has multiple ProductCategory records. You want to find products related to each other based on how many common categories they have (a.k.a using collaborative filtering). To do so, you can define a relationship in your Product model.
use MMedia\LaravelCollaborativeFiltering\HasCollaborativeFiltering; class Product extends Model { use HasCollaborativeFiltering; public function related() { return $this->hasManyRelatedThrough(ProductCategory::class, 'category_id'); } public function relatedThroughLikes() { return $this->hasManyRelatedThrough(ProductLikes::class, 'user_id'); } }
Based on the article from arctype.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email contact@mmediagroup.fr instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
统计信息
- 总下载量: 133
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-26