Include tutorial landing pages in sitemap and verify notification receipts
This commit is contained in:
1 parent
ace6d74a18
commit
252e0c38cb
7 files changed
+96
-17
No files matched your search
@@ -3,29 +3,33 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Articles;
|
||||
use App\Models\Categories;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class SitemapController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
// 连表查询分类:按 aOpt['noindexday'] 动态过滤过期文章
|
||||
// Use the same expiry rule as article metadata, including on SQLite in isolated tests.
|
||||
$cArticles = Articles::where('iStatus', 1)
|
||||
->whereHas('oCategory', function ($q) {
|
||||
$q->where(function ($query) {
|
||||
// 1. 没有配置 noindexday,或者 noindexday = 0 的文章,一直保留
|
||||
$query->whereNull('aOpt')
|
||||
->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(aOpt, '$.noindexday')) IS NULL")
|
||||
->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(aOpt, '$.noindexday')) = '0'")
|
||||
// 2. 配置了天数的,只取 N 天内创建的新文章
|
||||
->orWhereRaw("articles.created_at >= NOW() - INTERVAL CAST(JSON_UNQUOTE(JSON_EXTRACT(aOpt, '$.noindexday')) AS UNSIGNED) DAY");
|
||||
});
|
||||
})
|
||||
->where('created_at', '<=', now())
|
||||
->whereHas('oCategory', fn ($q) => $q->where('iStatus', 1))
|
||||
->with('oCategory')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
->get()->reject(fn ($article) => $article->bIsSeoExpired());
|
||||
|
||||
$visible = fn ($q) => $q->where('iStatus', 1)->where('created_at', '<=', now());
|
||||
$cCategories = Categories::whereIn('sSlug', ['client', 'advanced'])
|
||||
->where('iParentId', 0)->where('iStatus', 1)
|
||||
->where(function ($q) use ($visible) {
|
||||
$q->whereHas('aArticles', $visible)->orWhereHas('aChildren', function ($children) use ($visible) {
|
||||
$children->where('iStatus', 1)->whereHas('aArticles', $visible);
|
||||
});
|
||||
})->orderBy('sSlug')->get();
|
||||
|
||||
$sXmlContent = view('sitemap', [
|
||||
'cArticles' => $cArticles
|
||||
'cArticles' => $cArticles,
|
||||
'cCategories' => $cCategories,
|
||||
])->render();
|
||||
|
||||
return response($sXmlContent, 200)->header('Content-Type', 'text/xml');
|
||||
|
||||
Reference in new issue
Block a user