This commit is contained in:
f4ilji
2025-01-14 00:29:13 +05:00
parent dc33607de7
commit 45e73e27a0
7 changed files with 114 additions and 19 deletions
@@ -240,6 +240,12 @@ class FormBuilderItem
Builder\Block::make('captcha')
->label('reCaptcha')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->default('Капча')
->disabled(true)
->dehydrated(true),
Forms\Components\Hidden::make('name_field')->required()->default(Str::slug('reCaptcha') . Carbon::now()->timestamp),
Section::make('Настройка')
->collapsed()
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Observers;
use App\Models\MainSection;
use Illuminate\Support\Facades\Cache;
class MainSectionObserver
{
public function created(MainSection $mainSection): void
{
Cache::forget('navigation');
}
/**
* Очистка кеша при обновлении MainSection.
*
* @param MainSection $mainSection
* @return void
*/
public function updated(MainSection $mainSection)
{
Cache::forget('navigation');
}
/**
* Очистка кеша при удалении MainSection.
*
* @param MainSection $mainSection
* @return void
*/
public function deleted(MainSection $mainSection)
{
Cache::forget('navigation');
}
}
+3 -1
View File
@@ -12,7 +12,7 @@ class PageObserver
*/
public function created(Page $page): void
{
//
Cache::forget('navigation');
}
/**
@@ -22,6 +22,7 @@ class PageObserver
{
$cacheKey = 'page_' . md5($page->path);
Cache::forget($cacheKey);
Cache::forget('navigation');
}
/**
@@ -31,6 +32,7 @@ class PageObserver
{
$cacheKey = 'page_' . md5($page->path);
Cache::forget($cacheKey);
Cache::forget('navigation');
}
/**
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Observers;
use App\Models\SubSection;
use Illuminate\Support\Facades\Cache;
class SubSectionObserver
{
public function created(SubSection $subSection): void
{
Cache::forget('navigation');
}
/**
* Очистка кеша при обновлении SubSection.
*
* @param SubSection $subSection
* @return void
*/
public function updated(SubSection $subSection)
{
Cache::forget('navigation');
}
/**
* Очистка кеша при удалении SubSection.
*
* @param SubSection $subSection
* @return void
*/
public function deleted(SubSection $subSection)
{
Cache::forget('navigation');
}
}
+6
View File
@@ -2,10 +2,14 @@
namespace App\Providers;
use App\Models\MainSection;
use App\Models\Page;
use App\Models\Post;
use App\Models\SubSection;
use App\Observers\MainSectionObserver;
use App\Observers\PageObserver;
use App\Observers\PostObserver;
use App\Observers\SubSectionObserver;
use Carbon\Carbon;
use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Model;
@@ -33,6 +37,8 @@ class AppServiceProvider extends ServiceProvider
setlocale(LC_TIME, 'ru_RU.UTF-8');
Page::observe(PageObserver::class);
Post::observe(PostObserver::class);
MainSection::observe(MainSectionObserver::class);
SubSection::observe(SubSectionObserver::class);
Carbon::setLocale(config('app.locale'));
Model::preventLazyLoading(!app()->isProduction());
// URL::forceScheme('https');
@@ -1,20 +1,18 @@
<template>
<div class="mb-4 sm:mb-8">
<div class="relative">
<!-- Компонент капчи -->
<YSmartCaptcha v-model="token" />
<!-- Скрытое поле ввода -->
<input
v-model="token"
v-model="inputValue"
:required="block.data.rules.required"
:name="block.data.name_field"
type="text"
class="hidden"
>
/>
</div>
</div>
</template>
<script>
@@ -22,20 +20,29 @@ export default {
name: "CaptchaBlock",
data() {
return {
text: "",
token: null,
}
token: null, // Токен капчи
inputValue: "", // Значение, которое будет отправлено в input
};
},
watch: {
// Отслеживаем изменения токена
token(newToken) {
if (newToken) {
// Если токен получен, считаем капчу успешно пройденной
this.inputValue = "Капча успешно пройдена";
} else {
// Если токен сброшен, очищаем поле
this.inputValue = "";
}
},
},
methods: {},
props: {
block: {
type: Object,
},
error: {
type: Object,
}
},
},
}
</script>
};
</script>
@@ -4,11 +4,15 @@
<div class="">
<input
type="checkbox"
:name="block.data.name_field"
:value="block.data.name_field"
name="hs-default-radio"
required="required"
class="shrink-0 mb-0.5 border-gray-200 rounded text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none"
:id="block.data.name_field + '-id'">
<input
:name="block.data.name_field"
value="Даю согласие на обработку персональных данных"
type="text"
class="hidden"
/>
<label :for="block.data.name_field + '-id'" class="text-sm text-gray-500 ms-2">Даю свое согласие на сбор, обработку, хранение и использование персональных данных в соответствии с <a class="underline text-primaryBlue" target="_blank" href="https://ntspi.ru/upload/824_%D0%9E%D0%B1_%D1%83%D1%82%D0%B2_%D0%9F%D0%BE%D0%BB%D0%B8%D1%82_%D0%BE%D0%B1%D1%80_%D0%B7%D0%B0%D1%89%D0%B8%D1%82_%D0%BF%D0%B5%D1%80%D1%81_%D0%B4%D0%B0%D0%BD.pdf">Пользовательским соглашением</a> </label>
</div>
<p v-if="!error" class="mt-2 text-sm text-gray-500" id="hs-input-helper-text">{{ block.data.description }}</p>