1
0
Fork 0
mirror of https://github.com/archtechx/laravel-pages.git synced 2025-12-12 09:54:03 +00:00

add source code

This commit is contained in:
Samuel Štancl 2021-08-06 04:31:37 +02:00
commit e534ddd14c
23 changed files with 798 additions and 0 deletions

33
src/PageController.php Normal file
View file

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace ArchTech\Pages;
use Illuminate\Support\Str;
class PageController
{
public function __invoke(string $page)
{
if (str_starts_with($page, '_')) {
abort(404);
}
$view = config('pages.views.path') . $page;
if (view()->exists($view)) {
return view($view);
}
if ($model = config('pages.model')::find($page)) {
seo()
->title($model->title)
->description(Str::limit($model->content, 100));
return view(config('pages.views.markdown'), ['page' => $model]);
}
abort(404);
}
}