Skip to content

Getting recommendation for similar posts based on user likes #21

Pinned Answered by umutphp
Kyzegs asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Kyzegs ,

Many thanks for the question. Your case is very similiar to the Usecase 1 at README. So, for your case your Post model should as follows;

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Umutphp\LaravelModelRecommendation\InteractWithRecommendation;
use Umutphp\LaravelModelRecommendation\HasRecommendation;

class Post extends Model implements InteractWithRecommendation
{
    use HasFactory, HasRecommendation;

    public static function getRecommendationConfig() :array
    {
        return [
            'like' => [
                'recommendation_algorithm'         => 'db_relation',
                

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Kyzegs
Comment options

@umutphp
Comment options

Answer selected by umutphp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants