Update (major): Add search engine submission button
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user