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