Add (initial): futurewalker code
This commit is contained in:
@@ -12,14 +12,65 @@
|
||||
|
||||
class FrontListController extends Controller
|
||||
{
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
$page_type = 'search';
|
||||
|
||||
$query = $request->get('query', '');
|
||||
|
||||
$breadcrumbs = collect([
|
||||
['name' => 'Home', 'url' => route('front.home')],
|
||||
['name' => 'Search', 'url' => null],
|
||||
['name' => $query, 'url' => url()->current()],
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$title = 'Latest News about ' . ucwords($query) . ' in FutureWalker';
|
||||
|
||||
SEOTools::metatags();
|
||||
SEOTools::twitter();
|
||||
SEOTools::opengraph();
|
||||
SEOTools::jsonLd();
|
||||
SEOTools::setTitle($title, false);
|
||||
|
||||
// Use full-text search capabilities of your database
|
||||
// For example, using MySQL's full-text search with MATCH...AGAINST
|
||||
$posts = Post::with('category')
|
||||
->where('status', 'publish')
|
||||
->whereRaw("to_tsvector('english', title || ' ' || bites) @@ to_tsquery('english', ?)", [$query])
|
||||
->orderBy('published_at', 'desc')
|
||||
->cursorPaginate(10);
|
||||
|
||||
// breadcrumb json ld
|
||||
$listItems = [];
|
||||
|
||||
foreach ($breadcrumbs as $index => $breadcrumb) {
|
||||
$listItems[] = [
|
||||
'name' => $breadcrumb['name'],
|
||||
'url' => $breadcrumb['url'],
|
||||
];
|
||||
}
|
||||
|
||||
$breadcrumb_context = Context::create('breadcrumb_list', [
|
||||
'itemListElement' => $listItems,
|
||||
]);
|
||||
|
||||
return view('front.post_list', compact('posts', 'breadcrumbs', 'breadcrumb_context', 'title','page_type'));
|
||||
}
|
||||
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$page_type = 'default';
|
||||
|
||||
$breadcrumbs = collect([
|
||||
['name' => 'Home', 'url' => route('front.home')],
|
||||
['name' => 'Latest News', 'url' => null], // or you can set a route for Latest News if there's a specific one
|
||||
]);
|
||||
|
||||
$title = 'Latest News from EchoScoop';
|
||||
$title = 'Latest News from FutureWalker';
|
||||
|
||||
SEOTools::metatags();
|
||||
SEOTools::twitter();
|
||||
@@ -27,7 +78,7 @@ public function index(Request $request)
|
||||
SEOTools::jsonLd();
|
||||
SEOTools::setTitle($title, false);
|
||||
|
||||
$posts = Post::where('status', 'publish')->orderBy('published_at', 'desc')->simplePaginate(10) ?? collect();
|
||||
$posts = Post::with('category')->where('status', 'publish')->orderBy('published_at', 'desc')->cursorPaginate(10) ?? collect();
|
||||
|
||||
// breadcrumb json ld
|
||||
$listItems = [];
|
||||
@@ -39,15 +90,19 @@ public function index(Request $request)
|
||||
];
|
||||
}
|
||||
|
||||
//dd($posts);
|
||||
|
||||
$breadcrumb_context = Context::create('breadcrumb_list', [
|
||||
'itemListElement' => $listItems,
|
||||
]);
|
||||
|
||||
return view('front.post_list', compact('posts', 'breadcrumbs', 'breadcrumb_context'));
|
||||
return view('front.post_list', compact('posts', 'breadcrumbs', 'breadcrumb_context','page_type'));
|
||||
}
|
||||
|
||||
public function category(Request $request, $category_slug)
|
||||
{
|
||||
$page_type = 'default';
|
||||
|
||||
// Fetch the category by slug
|
||||
$category = Category::where('slug', $category_slug)->first();
|
||||
|
||||
@@ -68,9 +123,9 @@ public function category(Request $request, $category_slug)
|
||||
|
||||
// Get the posts associated with these category IDs
|
||||
$postIds = PostCategory::whereIn('category_id', $categoryIds)->pluck('post_id');
|
||||
$posts = Post::whereIn('id', $postIds)->where('status', 'publish')->orderBy('published_at', 'desc')->simplePaginate(10);
|
||||
$posts = Post::whereIn('id', $postIds)->where('status', 'publish')->orderBy('published_at', 'desc')->cursorPaginate(10);
|
||||
|
||||
$title = $category->name.' News from EchoScoop';
|
||||
$title = $category->name.' News from FutureWalker';
|
||||
|
||||
SEOTools::metatags();
|
||||
SEOTools::twitter();
|
||||
@@ -92,6 +147,6 @@ public function category(Request $request, $category_slug)
|
||||
'itemListElement' => $listItems,
|
||||
]);
|
||||
|
||||
return view('front.post_list', compact('category', 'posts', 'breadcrumbs', 'breadcrumb_context'));
|
||||
return view('front.post_list', compact('category', 'posts', 'breadcrumbs', 'breadcrumb_context','page_type'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user