getDriverName() === 'sqlite'; // 1. Featured story (Optimized using views_count index) $featuredQuery = Story::query(); if ($isSqlite) { $featuredQuery->from(DB::raw('stories INDEXED BY idx_stories_status_views_published')); } $featured = $featuredQuery->published() ->with(['author', 'category']) ->orderBy('views_count', 'desc') ->first(); $categories = Category::withCount('stories') ->whereNull('parent_id') ->take(8) ->get(); // Support filter tabs (latest, popular, long) and exclude featured story to prevent duplication $filter = $request->query('filter', 'latest'); $storiesQuery = Story::query(); if ($isSqlite) { if ($filter === 'popular') { $storiesQuery->from(DB::raw('stories INDEXED BY idx_stories_status_views_published')); } elseif ($filter === 'long') { $storiesQuery->from(DB::raw('stories INDEXED BY idx_stories_status_time_published')); } else { $storiesQuery->from(DB::raw('stories INDEXED BY idx_stories_status_created_published')); } } $storiesQuery->published()->with(['author', 'category']); if ($featured) { $storiesQuery->where('id', '!=', $featured->id); } if ($filter === 'popular') { $storiesQuery->orderBy('views_count', 'desc'); } elseif ($filter === 'long') { $storiesQuery->orderBy('reading_time_minutes', 'desc'); } else { $storiesQuery->latest(); } $stories = $storiesQuery->paginate(10)->withQueryString(); // 2. Trending stories (Optimized using views_count index) $trendingQuery = Story::query(); if ($isSqlite) { $trendingQuery->from(DB::raw('stories INDEXED BY idx_stories_status_views_published')); } $trendingStories = $trendingQuery->published() ->with(['author']) ->orderBy('views_count', 'desc') ->take(5) ->get(); $topAuthors = Author::withCount('stories') ->orderBy('stories_count', 'desc') ->take(5) ->get(); // Fetch the 5 most recent approved comments for the sidebar widget $latestComments = Comment::where('status', 'approved') ->with(['user', 'story']) ->latest() ->take(5) ->get(); return view('welcome', compact('featured', 'categories', 'stories', 'trendingStories', 'topAuthors', 'latestComments', 'filter'));})->name('home');Route::get('/search', function (Request $request) { $query = $request->input('q'); $stories = collect(); if ($query) { $storiesQuery = Story::published()->with(['author', 'category']); if (DB::connection()->getDriverName() === 'sqlite') { $storiesQuery->where(function ($q) use ($query) { $q->where('title', 'like', "%{$query}%") ->orWhere('summary', 'like', "%{$query}%") ->orWhere('content', 'like', "%{$query}%"); }); } else { // Use MySQL Fulltext index for sub-second search response times $storiesQuery->whereFullText(['title', 'summary', 'content'], $query . '*', ['mode' => 'boolean']); } $stories = $storiesQuery->latest()->paginate(12)->withQueryString(); } return view('search', compact('stories', 'query'));})->name('search');Route::get('/categories', function () { $categories = Category::withCount('stories')->get(); return view('category', [ 'category' => null, 'categories' => $categories, 'stories' => Story::published()->with(['author', 'category'])->latest()->paginate(12) ]);})->name('categories.index');Route::get('/category/{slug}', function ($slug) { $category = Category::where('slug', $slug)->firstOrFail(); $categories = Category::withCount('stories')->get(); $stories = Story::published() ->with(['author', 'category']) ->where('category_id', $category->id) ->latest() ->paginate(12); return view('category', compact('category', 'categories', 'stories'));})->name('category.show');Route::get('/trending', function () { $categories = Category::withCount('stories')->get(); $stories = Story::published() ->with(['author', 'category']) ->orderBy('views_count', 'desc') ->paginate(12); return view('category', [ 'category' => (object)[ 'name' => 'ट्रेडिंग कहानियां', 'description' => 'सबसे लोकप्रिय और सबसे ज्यादा पढ़ी जाने वाली कहानियां।' ], 'categories' => $categories, 'stories' => $stories ]);})->name('stories.trending');Route::get('/story/{slug}', function ($slug) { $story = Story::published() ->with(['author', 'category', 'tags', 'comments' => fn ($q) => $q->where('status', 'approved')->latest()]) ->where('slug', $slug) ->firstOrFail(); // Increment views $story->increment('views_count'); // Create raw view log StoryViewsLog::create([ 'story_id' => $story->id, 'user_id' => auth()->id(), 'ip_hash' => hash('sha256', request()->ip()), 'user_agent' => request()->userAgent() ]); // Fetch related stories $relatedStories = Story::published() ->with(['author', 'category']) ->where('category_id', $story->category_id) ->where('id', '!=', $story->id) ->take(3) ->get(); // SEO Interlinking & Series Detection from title (e.g. "Story Name - 2") $seriesStories = collect(); $prevStory = null; $nextStory = null; if (preg_match('/^(.+?)\s*-\s*(\d+)$/u', $story->title, $matches)) { $baseTitle = trim($matches[1]); $currentPart = (int)$matches[2]; // Fetch all stories belonging to the same series $allSeriesParts = Story::published() ->select('id', 'title', 'slug') ->where('title', 'LIKE', $baseTitle . '%') ->get(); $parsedParts = []; foreach ($allSeriesParts as $partStory) { if (preg_match('/^(.+?)\s*-\s*(\d+)$/u', $partStory->title, $partMatches)) { if (trim($partMatches[1]) === $baseTitle) { $partNum = (int)$partMatches[2]; $partStory->part_number = $partNum; $parsedParts[] = $partStory; } } } // Sort by part number usort($parsedParts, function ($a, $b) { return $a->part_number <=> $b->part_number; }); if (count($parsedParts) > 1) { $seriesStories = collect($parsedParts); // Find next and previous parts in the sorted series foreach ($parsedParts as $partStory) { if ($partStory->part_number === $currentPart + 1) { $nextStory = $partStory; } if ($partStory->part_number === $currentPart - 1) { $prevStory = $partStory; } } } } // Fallback: Default sequential links if not part of a series or missing siblings $baseTitle = isset($baseTitle) ? $baseTitle : ''; if (!$prevStory) { $query = Story::published() ->select('id', 'title', 'slug') ->where('id', '<', $story->id); if ($baseTitle) { $query->where('title', 'NOT LIKE', $baseTitle . '%'); } $prevStory = $query->orderBy('id', 'desc')->first(); } if (!$nextStory) { $query = Story::published() ->select('id', 'title', 'slug') ->where('id', '>', $story->id); if ($baseTitle) { $query->where('title', 'NOT LIKE', $baseTitle . '%'); } $nextStory = $query->orderBy('id', 'asc')->first(); } return view('story', compact('story', 'relatedStories', 'prevStory', 'nextStory', 'seriesStories'));})->name('stories.show');Route::get('/author/{slug}', function ($slug) { $matchedAuthorId = Author::select('id', 'pen_name') ->get() ->first(function ($auth) use ($slug) { return Str::slug($auth->pen_name) === $slug; })?->id; if (!$matchedAuthorId) { abort(404); } $author = Author::findOrFail($matchedAuthorId); $stories = Story::published() ->with(['author', 'category']) ->where('author_id', $author->id) ->latest() ->paginate(12); return view('author', compact('author', 'stories'));})->name('author.show');Route::get('/sitemap.xml', function () { $stories = Story::published() ->select('slug', 'title', 'summary', 'cover_image_path', 'created_at', 'updated_at') ->orderBy('updated_at', 'desc') ->get(); $categories = Category::select('slug')->get(); $authors = Author::select('pen_name')->get(); return response()->view('sitemap', compact('stories', 'categories', 'authors')) ->header('Content-Type', 'text/xml');})->name('sitemap');Route::get('/about', function () { return view('about');})->name('about');Route::get('/contact', function () { return view('contact');})->name('contact');Route::post('/contact', function (Request $request) { $request->validate([ 'name' => 'required|string|max:100', 'email' => 'required|email|max:100', 'subject' => 'required|string|max:150', 'message' => 'required|string|max:2000', ]); // Redirect back with success message return back()->with('success', 'आपका संदेश सफलतापूर्वक प्राप्त हो गया है! हमारी टीम जल्द ही आपसे संपर्क करेगी।');})->name('contact.submit');Route::get('/privacy-policy', function () { return view('privacy');})->name('privacy');Route::get('/terms', function () { return view('terms');})->name('terms');Route::post('/newsletter/subscribe', function () { return back()->with('success', 'न्यूज़लेटर सब्सक्राइब करने के लिए धन्यवाद!');})->name('newsletter.subscribe');Route::post('/story/{slug}/comment', function (Request $request, $slug) { $request->validate([ 'name' => 'required|string|max:100', 'content' => 'required|string|max:1000', ]); $content = $request->input('content'); // Check if content contains links or URLs $hasLink = preg_match('/https?:\/\/\S+/i', $content) || preg_match('/www\.\S+/i', $content) || preg_match('/\b[a-zA-Z0-9.-]+\.(com|net|org|info|in|co|xyz|me|club|io)\b/i', $content); if ($hasLink) { return back()->withErrors([ 'content' => 'कमेंट में लिंक या वेबसाइट (URLs) डालने की अनुमति नहीं है।' ])->withInput(); } $story = Story::published()->where('slug', $slug)->firstOrFail(); // Find or create guest user $name = trim($request->input('name')); $user = User::where('name', $name)->first(); if (!$user) { $user = User::create([ 'name' => $name, 'email' => Str::slug($name) . '_' . uniqid() . '@guest.mohakkisse.com', 'password' => bcrypt(Str::random(16)), 'role' => 'user', ]); } Comment::create([ 'user_id' => $user->id, 'story_id' => $story->id, 'content' => $request->input('content'), 'status' => 'pending', // Default to pending for admin moderation ]); return back()->with('comment_success', 'आपकी प्रतिक्रिया सफलतापूर्वक प्राप्त हो गई है और यह मॉडरेशन के बाद दिखाई देगी।');})->name('comments.store');Route::post('/story/{slug}/react', function (Request $request, $slug) { $request->validate([ 'type' => 'required|string|in:likes,loves,hots', ]); $story = Story::published()->where('slug', $slug)->firstOrFail(); $type = $request->input('type'); if ($type === 'likes') { $story->increment('likes_count'); } elseif ($type === 'loves') { $story->increment('loves_count'); } elseif ($type === 'hots') { $story->increment('hots_count'); } return response()->json([ 'success' => true, 'likes' => $story->likes_count, 'loves' => $story->loves_count, 'hots' => $story->hots_count, ]);})->name('stories.react');
Cannot modify header information - headers already sent by (output started at /home/u981603309/domains/mohakkisse.com/public_html/routes/web.php:1)
header_remove()25 $response->headers->remove('Server');26 }2728 // Remove from PHP's global header list (fallback)29 if (function_exists('header_remove')) {30 header_remove('X-Powered-By');31 header_remove('Server');32 }3334 return $response;35 }36}37App\Http\Middleware\RemoveHeaders->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()Illuminate\Foundation\Http\Middleware\TrimStrings->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Http\Middleware\ValidatePostSize->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Http\Middleware\HandleCors->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Http\Middleware\TrustProxies->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Http\Middleware\ValidatePathEncoding->handle()Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()Illuminate\Pipeline\Pipeline->then()Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()Illuminate\Foundation\Http\Kernel->handle()Illuminate\Foundation\Application->handleRequest()2021// Bootstrap Laravel and handle the request...22/** @var Application $app */23$app = require_once __DIR__.'/../bootstrap/app.php';2425$app->handleRequest(Request::capture());26{
"page": "20"
}