Add (auto indexing): when set to publish

This commit is contained in:
2023-09-10 21:48:39 +08:00
parent ef58f62e57
commit 645d0f1d02
4 changed files with 43 additions and 26 deletions

View File

@@ -125,6 +125,14 @@ public function postUpsert(Request $request)
]);
}
if ($existingPost->status == 'publish') {
$post_url = route('home.country.post', ['country' => $existingPost->post_category?->category?->country_locale_slug, 'post_slug' => $existingPost->slug]);
LaravelGoogleIndexing::create()->update($post_url);
IndexNow::submit($post_url);
}
// Return a response indicating a successful update
return response()->json(['message' => 'Post updated successfully', 'action' => 'redirect_back']);
} else {
@@ -143,6 +151,13 @@ public function postUpsert(Request $request)
]);
}
if ($newPost->status == 'publish') {
$post_url = route('home.country.post', ['country' => $newPost->post_category?->category?->country_locale_slug, 'post_slug' => $newPost->slug]);
LaravelGoogleIndexing::create()->update($post_url);
IndexNow::submit($post_url);
}
// Return a response indicating a successful creation
return response()->json(['message' => 'Post created successfully', 'action' => 'redirect_back']);
}