This commit is contained in:
f4ilji
2024-12-24 18:43:59 +05:00
parent 99e012d727
commit ed7ac493a0
9 changed files with 32 additions and 21 deletions
@@ -27,6 +27,21 @@ use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class ContentBuilderItem
{
private static function findSeoActive(array $data) : bool
{
$bool = false;
foreach ($data as $item) {
if ($item['type'] !== 'paragraph') {
continue;
}
if ($item['data']['seo_active'] === true) {
$bool = true;
break;
}
}
return $bool;
}
public static function getItem(string $name)
{
return
@@ -42,6 +57,14 @@ class ContentBuilderItem
]),
Builder\Block::make('paragraph')
->schema([
Toggle::make('seo_active')->label('Использовать блок как seo')
->live(onBlur: true)
->required()
->disabled(function ($state, Forms\Get $get) {
$data = $get('../../');
return self::findSeoActive($data) && !$state;
})
->dehydrated(),
TinyEditor::make('content')
->label('')
->profile('test')
@@ -37,21 +37,7 @@ use Symfony\Component\Finder\Finder;
class PostForm
{
private static function findSeoActive(array $data) : bool
{
$bool = false;
foreach ($data as $item) {
if ($item['type'] !== 'paragraph') {
continue;
}
if ($item['data']['seo_active'] === true) {
$bool = true;
break;
}
}
return $bool;
}
public static function getForm(Form $form): Form
{
return $form