Update (major): Add search engine submission button

This commit is contained in:
2023-08-02 00:04:44 +08:00
parent f25fea8d68
commit 592637b0b3
31 changed files with 1346 additions and 75 deletions

View File

@@ -6,6 +6,8 @@
use App\Models\Post;
use App\Models\PostCategory;
use Illuminate\Http\Request;
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
use LaravelGoogleIndexing;
class PostController extends Controller
{
@@ -35,6 +37,24 @@ public function edit(Request $request, $post_id)
return redirect()->back()->with('error', 'Post does not exist.');
}
public function indexing(Request $request, $post_id)
{
$post = Post::find($post_id);
if (! is_null($post)) {
$post_url = route('home.country.post', ['country' => $post->post_category?->category?->country_locale_slug, 'post_slug' => $post->slug]);
LaravelGoogleIndexing::create()->update($post_url);
IndexNow::submit($post_url);
return redirect()->back()->with('success', 'Signalled Google for Indexing.');
}
return redirect()->back()->with('error', 'Something went wrong.');
}
public function postUpsert(Request $request)
{