This commit is contained in:
ct
2025-07-07 21:17:00 +08:00
parent 23fa3aec04
commit 6a66f96d22
31 changed files with 227 additions and 232 deletions

View File

@@ -152,7 +152,6 @@ public static function generateMemeByKeyword($keyword)
return $meme;
}
public static function generateMemeOutputByKeyword($keyword, $category = null)
{
@@ -203,7 +202,7 @@ public static function generateMemeOutputByKeyword($keyword, $category = null)
$meme_output = (object) [
'success' => false,
'attempts' => $attempt, // Optional: track how many attempts were made
'error' => 'Failed to generate valid meme after ' . $retries . ' attempts',
'error' => 'Failed to generate valid meme after '.$retries.' attempts',
];
}
@@ -216,13 +215,13 @@ public static function generateMemeOutputByCategory(Category $category)
$random_keyword = Str::lower($category->name);
if (! is_null($category->parent_id)) {
$random_keyword = $category->parent->name . ' - ' . $random_keyword;
$random_keyword = $category->parent->name.' - '.$random_keyword;
}
if (! is_null($category->meme_angles)) {
$random_keyword .= ' - ' . collect($category->meme_angles)->random();
$random_keyword .= ' - '.collect($category->meme_angles)->random();
} elseif (! is_null($category->keywords)) {
$random_keyword .= ' - ' . collect($category->keywords)->random();
$random_keyword .= ' - '.collect($category->keywords)->random();
}
return self::generateMemeOutputByKeyword($random_keyword, $category);