<?php
namespace App\Http\Controllers;
use App\Models\BlogPost;
use Artesaos\SEOTools\Facades\SEOTools;
class BlogController extends Controller {
public function index(string $lang) {
SEOTools::setTitle('Blog | Chandra & Sons Pharma');
SEOTools::setDescription('Healthcare insights, pharmaceutical news, and industry updates from Chandra & Sons Pharma Distributors.');
$posts = BlogPost::published()->paginate(12);
return view('pages.blog.index', ['lang' => $lang, 'posts' => $posts]);
}
public function show(string $lang, string $slug) {
$post = BlogPost::where('slug', $slug)->where('status', 'published')->firstOrFail();
SEOTools::setTitle(($post->meta_title ?: $post->title) . ' | Chandra & Sons');
SEOTools::setDescription($post->meta_description ?: $post->excerpt);
if ($post->og_image ?: $post->featured_image) \Artesaos\SEOTools\Facades\OpenGraph::addImage(asset('storage/'.($post->og_image ?: $post->featured_image)));
return view('pages.blog.show', ['lang' => $lang, 'post' => $post]);
}
}