Add (initial): futurewalker code
This commit is contained in:
@@ -13,12 +13,18 @@ class FrontHomeController extends Controller
|
||||
{
|
||||
public function home(Request $request)
|
||||
{
|
||||
$featured_post = Post::where('status', 'publish')->orderBy('published_at', 'desc')->first();
|
||||
$latest_posts = Post::where(function ($query) use ($featured_post) {
|
||||
$query->whereNotIn('id', [$featured_post?->id]);
|
||||
})->where('status', 'publish')->orderBy('published_at', 'desc')->limit(5)->get();
|
||||
// $featured_post = Post::where('status', 'publish')->orderBy('published_at', 'desc')->first();
|
||||
// $latest_posts = Post::where(function ($query) use ($featured_post) {
|
||||
// $query->whereNotIn('id', [$featured_post?->id]);
|
||||
// })->where('status', 'publish')->orderBy('published_at', 'desc')->limit(5)->get();
|
||||
|
||||
return response(view('front.welcome', compact('featured_post', 'latest_posts')), 200);
|
||||
$featured_posts = Post::where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(6)->get();
|
||||
|
||||
$latest_posts = Post::where(function ($query) use ($featured_posts) {
|
||||
$query->whereNotIn('id', $featured_posts->pluck('id')->toArray());
|
||||
})->where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(6)->get();
|
||||
|
||||
return response(view('front.welcome', compact('featured_posts', 'latest_posts')), 200);
|
||||
}
|
||||
|
||||
public function terms(Request $request)
|
||||
@@ -70,7 +76,7 @@ public function disclaimer(Request $request)
|
||||
$markdown = file_get_contents(resource_path('markdown/disclaimer.md'));
|
||||
|
||||
$title = 'Disclaimer';
|
||||
$description = 'EchoScoop provides the content on this website purely for informational purposes and should not be interpreted as legal, financial, or medical guidance.';
|
||||
$description = 'FutureWalker provides the content on this website purely for informational purposes and should not be interpreted as legal, financial, or medical guidance.';
|
||||
|
||||
SEOTools::metatags();
|
||||
SEOTools::twitter();
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public function index(Request $request, $category_slug, $slug)
|
||||
$content = $this->injectFeaturedImage($post, $content);
|
||||
$content = $this->injectPublishDateAndAuthor($post, $content);
|
||||
|
||||
$post_description = $post->excerpt.' '.$post->title.' by EchoScoop.';
|
||||
$post_description = $post->excerpt.' '.$post->title.' by FutureWalker.';
|
||||
|
||||
// Generate breadcrumb data
|
||||
$breadcrumbs = collect([
|
||||
@@ -71,7 +71,6 @@ public function index(Request $request, $category_slug, $slug)
|
||||
SEOMeta::setTitle($post->title, false);
|
||||
SEOMeta::setDescription($post_description);
|
||||
SEOMeta::addMeta('article:published_time', $post->published_at->format('Y-m-d'), 'property');
|
||||
SEOMeta::addMeta('article:section', $post->category->name, 'property');
|
||||
SEOMeta::setRobots('INDEX, FOLLOW, MAX-IMAGE-PREVIEW:LARGE, MAX-SNIPPET:-1, MAX-VIDEO-PREVIEW:-1');
|
||||
|
||||
OpenGraph::setDescription($post_description);
|
||||
@@ -89,15 +88,15 @@ public function index(Request $request, $category_slug, $slug)
|
||||
->addImage($post->featured_image_cdn)
|
||||
->addValue('author', [
|
||||
'type' => 'Person',
|
||||
'name' => $post->author->name,
|
||||
'name' => 'FutureWalker',
|
||||
'url' => config('app.url'),
|
||||
])
|
||||
->addValue('publisher', [
|
||||
'type' => 'Organization',
|
||||
'name' => 'EchoScoop',
|
||||
'name' => 'FutureWalker',
|
||||
'logo' => [
|
||||
'type' => 'ImageObject',
|
||||
'url' => asset('echoscoop-logo-512x512.png'),
|
||||
'url' => asset('FutureWalker-logo-512x512.png'),
|
||||
],
|
||||
])
|
||||
->addValue('datePublished', $post->published_at->format('Y-m-d'))
|
||||
@@ -231,7 +230,7 @@ private function injectTableOfContents($html)
|
||||
private function injectPublishDateAndAuthor($post, $content)
|
||||
{
|
||||
$publishedAtFormatted = $post->published_at->format('F j, Y');
|
||||
$authorName = $post->author->name;
|
||||
$authorName = 'FutureWalker Team';
|
||||
|
||||
// Create the HTML structure for publish date and author
|
||||
$publishInfo = "<div class=\"mb-4\"><span class=\"text-secondary small\">Published on {$publishedAtFormatted} by {$authorName}<i class=\"bi bi-dot\"></i>".markdown_min_read($post->body).'</span></div>';
|
||||
|
||||
Reference in New Issue
Block a user