MyHomeCollection/app/Http/Controllers/PublicController.php
Shikiryu 5442bf19b0 Ajoute le module SEO
Pour #8

Co-authored-by: Clement <clement@desmidt.fr>
Reviewed-on: #12
2020-07-27 12:02:57 +02:00

30 lines
794 B
PHP

<?php
namespace App\Http\Controllers;
use App\Home;
use Artesaos\SEOTools\Traits\SEOTools as SEOToolsTrait;
use DateTime;
class PublicController extends Controller
{
use SEOToolsTrait;
public function show($slug)
{
$home = Home::where('slug', $slug)->firstOrFail();
$this->seo()
->setTitle($home->title)
->setDescription($home->excerpt())
->addImages(array_map(static function($picture) {
return asset($picture);
}, $home->pictures));
$this->seo()
->opengraph()
->addProperty('article:published_time', $home->created_at->format(DateTime::ATOM))
->addProperty('article:author', 'Shikiryu');
return view('public.view', ['home' => $home]);
}
}