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