This commit is contained in:
f4ilji
2024-10-04 12:48:19 +05:00
parent 21a6e9073b
commit cebc584a14
303 changed files with 8224 additions and 2563 deletions
@@ -12,37 +12,4 @@ use Filament\Resources\Pages\CreateRecord;
class CreateSubSection extends CreateRecord
{
protected static string $resource = SubSectionResource::class;
protected array $page_ids;
protected function mutateFormDataBeforeCreate(array $data): array
{
$this->page_ids = $data['page_ids'];
unset($data['page_ids']);
return $data;
}
protected function afterCreate(): void
{
if ($this->page_ids != null) {
Page::whereIn('id', $this->page_ids)->update(['sub_section_id' => $this->record->id]);
$pages = Page::where('is_url', '=', false)->where('sub_section_id', '=', $this->record->id)->get();
if (!$pages->isEmpty()) {
$mainSectionSlug = ($pages[0]->section->mainSection) ? $pages[0]->section->mainSection->slug : '';
foreach ($pages as $page) {
if ($page->is_registered != true) {
$page->update(['path' => $page->path = $mainSectionSlug . '/' . $this->record->slug . '/' . $page->slug]);
}
}
}
}
}
}