fix: 🐛 fix schema condition to prevents loop between recipe and product models
This commit is contained in:
parent
5e684c6c02
commit
aac04b4ca5
2 changed files with 3 additions and 3 deletions
|
|
@ -293,7 +293,7 @@ class Product extends Model implements SeoInterface, Sitemapable, SchemaOrgInter
|
|||
// Recipes associated.
|
||||
if ($model->recipes->count() && !$asReference) {
|
||||
$schema->subjectOf($model->recipes->where('published', true)->map(function (Recipe $recipe) {
|
||||
return $recipe->toSchemaOrg();
|
||||
return $recipe->toSchemaOrg(true);
|
||||
})->toArray());
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ class Product extends Model implements SeoInterface, Sitemapable, SchemaOrgInter
|
|||
} else {
|
||||
array_push($categories, $model->subrange->toSchemaOrg());
|
||||
}
|
||||
if ($model->load('claims')->meat_id) {
|
||||
if ($model->meat_id) {
|
||||
array_push($categories, $model->meat->toSchemaOrg());
|
||||
} else {
|
||||
array_push($categories, $model->submeat->toSchemaOrg());
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ class Recipe extends Model implements SeoInterface, Sitemapable, SchemaOrgInterf
|
|||
$schema->recipeIngredient($ingredientsList);
|
||||
|
||||
// Products associated.
|
||||
if (!$asReference) {
|
||||
if ($model->products->count() && !$asReference) {
|
||||
$linkedProducts = $model->products->map(function (Product $product) {
|
||||
return $product->toSchemaOrg(true);
|
||||
})->toArray();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue