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') Builder\Block::make('captcha')
->label('reCaptcha') ->label('reCaptcha')
->schema([ ->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), Forms\Components\Hidden::make('name_field')->required()->default(Str::slug('reCaptcha') . Carbon::now()->timestamp),
Section::make('Настройка') Section::make('Настройка')
->collapsed() ->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 public function created(Page $page): void
{ {
// Cache::forget('navigation');
} }
/** /**
@@ -22,6 +22,7 @@ class PageObserver
{ {
$cacheKey = 'page_' . md5($page->path); $cacheKey = 'page_' . md5($page->path);
Cache::forget($cacheKey); Cache::forget($cacheKey);
Cache::forget('navigation');
} }
/** /**
@@ -31,6 +32,7 @@ class PageObserver
{ {
$cacheKey = 'page_' . md5($page->path); $cacheKey = 'page_' . md5($page->path);
Cache::forget($cacheKey); 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; namespace App\Providers;
use App\Models\MainSection;
use App\Models\Page; use App\Models\Page;
use App\Models\Post; use App\Models\Post;
use App\Models\SubSection;
use App\Observers\MainSectionObserver;
use App\Observers\PageObserver; use App\Observers\PageObserver;
use App\Observers\PostObserver; use App\Observers\PostObserver;
use App\Observers\SubSectionObserver;
use Carbon\Carbon; use Carbon\Carbon;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@@ -33,6 +37,8 @@ class AppServiceProvider extends ServiceProvider
setlocale(LC_TIME, 'ru_RU.UTF-8'); setlocale(LC_TIME, 'ru_RU.UTF-8');
Page::observe(PageObserver::class); Page::observe(PageObserver::class);
Post::observe(PostObserver::class); Post::observe(PostObserver::class);
MainSection::observe(MainSectionObserver::class);
SubSection::observe(SubSectionObserver::class);
Carbon::setLocale(config('app.locale')); Carbon::setLocale(config('app.locale'));
Model::preventLazyLoading(!app()->isProduction()); Model::preventLazyLoading(!app()->isProduction());
// URL::forceScheme('https'); // URL::forceScheme('https');
@@ -1,20 +1,18 @@
<template> <template>
<div class="mb-4 sm:mb-8"> <div class="mb-4 sm:mb-8">
<div class="relative"> <div class="relative">
<!-- Компонент капчи -->
<YSmartCaptcha v-model="token" /> <YSmartCaptcha v-model="token" />
<!-- Скрытое поле ввода -->
<input <input
v-model="token" v-model="inputValue"
:required="block.data.rules.required" :required="block.data.rules.required"
:name="block.data.name_field" :name="block.data.name_field"
type="text" type="text"
class="hidden" class="hidden"
> />
</div> </div>
</div> </div>
</template> </template>
<script> <script>
@@ -22,20 +20,29 @@ export default {
name: "CaptchaBlock", name: "CaptchaBlock",
data() { data() {
return { return {
text: "", token: null, // Токен капчи
token: null, inputValue: "", // Значение, которое будет отправлено в input
};
},
watch: {
// Отслеживаем изменения токена
token(newToken) {
if (newToken) {
// Если токен получен, считаем капчу успешно пройденной
this.inputValue = "Капча успешно пройдена";
} else {
// Если токен сброшен, очищаем поле
this.inputValue = "";
} }
}, },
methods: {}, },
props: { props: {
block: { block: {
type: Object, type: Object,
}, },
error: { error: {
type: Object, type: Object,
}
}, },
} },
};
</script> </script>
@@ -4,11 +4,15 @@
<div class=""> <div class="">
<input <input
type="checkbox" type="checkbox"
:name="block.data.name_field" required="required"
:value="block.data.name_field"
name="hs-default-radio"
class="shrink-0 mb-0.5 border-gray-200 rounded text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none" 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'"> :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> <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> </div>
<p v-if="!error" class="mt-2 text-sm text-gray-500" id="hs-input-helper-text">{{ block.data.description }}</p> <p v-if="!error" class="mt-2 text-sm text-gray-500" id="hs-input-helper-text">{{ block.data.description }}</p>