Skip to content

Commit

Permalink
Merge pull request #25 from RaidOuahioune/RaidOuahioune-patch-1-1
Browse files Browse the repository at this point in the history
fix quering from the source model && hardcoded target type
  • Loading branch information
umutphp committed Nov 22, 2023
2 parents d005c2d + 2a1a379 commit 1e11e87
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/HasRecommendation.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,20 @@ public static function calculateSimilarityMatrix($models, $config): array
public function getRecommendations($name)
{
$config = $this->getRecommendationConfig()[$name] ?? null;
$model=$config['recommendation_data_field_type']??self::class;

if ($config === null) {
return [];
}

$recommendations = RecommendationsModel::where('source_type', self::class)
->where('recommendation_name', $name)
->where('target_type', self::class)
->where('target_type', $model)
->where('source_id', $this->id)
->get();


$return = $this->whereIn('id', $recommendations->pluck('target_id'))->get();
$return = $model::query()->whereIn('id', $recommendations->pluck('target_id'))->get();

$order = $config['recommendation_order'] ?? config('laravel_model_recommendation.recommendation_count');

Expand Down

0 comments on commit 1e11e87

Please sign in to comment.