Files
futurewalker/app/Http/Controllers/Front/FrontHomeController.php
2023-12-03 11:20:03 +08:00

106 lines
3.9 KiB
PHP

<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use App\Models\HybridTopRssPostKeywords;
use App\Models\Post;
use App\Models\RssPost;
use Artesaos\SEOTools\Facades\SEOMeta;
use Artesaos\SEOTools\Facades\SEOTools;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Http\Request;
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_posts = Post::where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(3)->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(10)->get();
$rss_count = RssPost::where('status', 'published')
->where('published_at', '>=', now()->subDay())
->count();
$top_rss_keywords = HybridTopRssPostKeywords::get(1, 16);
$rss_posts = RssPost::with('entities_keywords')->whereNotNull('keywords')->where('status', 'published')->orderBy('published_at', 'desc')->paginate(30);
return response(view('front.welcome', compact('rss_posts', 'top_rss_keywords', 'rss_count')), 200);
}
public function terms(Request $request)
{
$markdown = file_get_contents(resource_path('markdown/terms.md'));
$title = 'Terms of Service';
$description = 'Our Terms of Service outline your rights, responsibilities, and the standards we uphold for a seamless experience.';
SEOTools::metatags();
SEOTools::twitter();
SEOTools::opengraph();
SEOTools::jsonLd();
SEOTools::setTitle($title);
SEOTools::setDescription($description);
SEOMeta::setRobots('noindex');
$content = Markdown::convert($markdown)->getContent();
//$content = $this->injectTailwindClasses($content);
return view('front.pages', compact('content', 'title', 'description'));
}
public function privacy(Request $request)
{
$markdown = file_get_contents(resource_path('markdown/privacy.md'));
$title = 'Privacy Policy';
$description = 'Our Privacy Policy provides clarity about the data we collect and how we use it, ensuring your peace of mind.';
SEOTools::metatags();
SEOTools::twitter();
SEOTools::opengraph();
SEOTools::jsonLd();
SEOTools::setTitle($title);
SEOTools::setDescription($description);
SEOMeta::setRobots('noindex');
$content = Markdown::convert($markdown)->getContent();
//$content = $this->injectTailwindClasses($content);
return view('front.pages', compact('content', 'title', 'description'));
}
public function disclaimer(Request $request)
{
$markdown = file_get_contents(resource_path('markdown/disclaimer.md'));
$title = 'Disclaimer';
$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();
SEOTools::opengraph();
SEOTools::jsonLd();
SEOTools::setTitle($title);
SEOTools::setDescription($description);
SEOMeta::setRobots('noindex');
$content = Markdown::convert($markdown)->getContent();
//$content = $this->injectTailwindClasses($content);
return view('front.pages', compact('content', 'title', 'description'));
}
}