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

Add password protected pages (resolve #3)

This commit is contained in:
Samuel Štancl 2021-08-08 20:01:14 +02:00
parent e9d1cd6fe7
commit c0c4ebe0d0
5 changed files with 23 additions and 4 deletions

View file

@ -19,6 +19,7 @@ class Page extends Model
{
$table->string('slug');
$table->string('title');
$table->string('password')->nullable();
$table->longText('content');
}

View file

@ -21,6 +21,10 @@ class PageController
}
if ($model = config('pages.model')::find($page)) {
if ($model->password) {
abort_unless(request()->query('password') === $model->password, 403);
}
seo()
->title($model->title)
->description(Str::limit($model->content, 100));