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 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) public static function getItem(string $name)
{ {
return return
@@ -42,6 +57,14 @@ class ContentBuilderItem
]), ]),
Builder\Block::make('paragraph') Builder\Block::make('paragraph')
->schema([ ->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') TinyEditor::make('content')
->label('') ->label('')
->profile('test') ->profile('test')
@@ -37,21 +37,7 @@ use Symfony\Component\Finder\Finder;
class PostForm 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 public static function getForm(Form $form): Form
{ {
return $form return $form
@@ -134,7 +134,7 @@ class ClientAdditionalEducationController extends Controller
$breadcrumbs = null; $breadcrumbs = null;
} }
$seo = $additionalEducation->seo; $seo = $additionalEducation->seo ?? null;
return Inertia::render('Client/Additional-educations/Show', compact('additionalEducation', 'breadcrumbs', 'seo')); return Inertia::render('Client/Additional-educations/Show', compact('additionalEducation', 'breadcrumbs', 'seo'));
} }
@@ -28,7 +28,7 @@ class ClientDepartmentController extends Controller
->first()); ->first());
$directions = $this->groupProgramsByDirection($department->programs); $directions = $this->groupProgramsByDirection($department->programs);
$seo = $department->seo; $seo = $department->seo ?? null;
return Inertia::render('Client/Departments/Show', compact('department', 'departments', 'directions', 'seo')); return Inertia::render('Client/Departments/Show', compact('department', 'departments', 'directions', 'seo'));
} }
@@ -19,7 +19,7 @@ class ClientDivisionController extends Controller
{ {
$divisions = DivisionResource::collection(Division::query()->where('is_active', true)->get()); $divisions = DivisionResource::collection(Division::query()->where('is_active', true)->get());
$division = new DivisionResource(Division::with('workers.userDetail')->where('is_active', true)->where('slug', $slug)->firstOrFail()); $division = new DivisionResource(Division::with('workers.userDetail')->where('is_active', true)->where('slug', $slug)->firstOrFail());
$seo = $division->seo; $seo = $division->seo ?? null;
return Inertia::render('Client/Divisions/Show', compact('divisions', 'division', 'seo')); return Inertia::render('Client/Divisions/Show', compact('divisions', 'division', 'seo'));
} }
} }
@@ -66,7 +66,7 @@ class ClientEventController extends Controller
$breadcrumbs = null; $breadcrumbs = null;
} }
$seo = $event->seo; $seo = $event->seo ?? null;
return Inertia::render('Client/Events/Show', compact('event', 'breadcrumbs', 'seo')); return Inertia::render('Client/Events/Show', compact('event', 'breadcrumbs', 'seo'));
} }
@@ -144,7 +144,8 @@ class ClientPostController extends Controller
$breadcrumbs = null; $breadcrumbs = null;
} }
$seo = $post->seo; $seo = $post->seo ?? null;
return Inertia::render('Client/Posts/Show', compact('post', 'breadcrumbs', 'seo')); return Inertia::render('Client/Posts/Show', compact('post', 'breadcrumbs', 'seo'));
} }
@@ -120,7 +120,7 @@ class ClientProgramController extends Controller
return [$formEducational->value => $formEducational->getLabel()]; return [$formEducational->value => $formEducational->getLabel()];
}); });
$seo = $program->seo; $seo = $program->seo ?? null;
return Inertia::render('Client/Programs/Show', compact('program', 'formsEdu', 'seo')); return Inertia::render('Client/Programs/Show', compact('program', 'formsEdu', 'seo'));
} }
+2 -1
View File
@@ -40,7 +40,8 @@ class PageController extends Controller
$breadcrumbs = null; $breadcrumbs = null;
} }
$seo = $page->seo; $seo = $page->seo ?? null;
$page = new PageResource($page); $page = new PageResource($page);