PHP code example of mmedia / laravel-collaborative-filtering
1. Go to this page and download the library: Download mmedia/laravel-collaborative-filtering library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mmedia / laravel-collaborative-filtering example snippets
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');
}
}