Rework frontend

This commit is contained in:
F4ilji
2025-04-02 18:09:54 +05:00
parent 49072e50c7
commit bd3a4408b1
197 changed files with 9715 additions and 6664 deletions
@@ -3,42 +3,27 @@
namespace App\Filament\Resources\DivisionResource\Pages;
use App\Filament\Resources\DivisionResource;
use App\Services\Filament\Traits\SeoGenerate;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Support\Str;
class CreateDivision extends CreateRecord
{
protected static string $resource = DivisionResource::class;
use SeoGenerate;
protected array $seoData;
protected static string $resource = DivisionResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
$this->seoData = $this->generateSeo($data);
$data['search_data'] = $this->generateSearchData($data['description']);
return $data;
}
protected function afterCreate(): void
{
$this->record->seo()->create($this->seoData);
}
private function generateSeo(array $data) : array
{
$title = $data['title'];
$rowData = $this->getFirstBlockByName('paragraph', $data['description']);
if ($rowData !== null) {
$description = strip_tags($rowData['data']['content']);
} else {
$description = null;
}
return [
'title' => $title,
'description' => Str::limit(htmlspecialchars($description, ENT_QUOTES, 'UTF-8'), 160),
];
$this->createSeo($this->record);
}
private function generateSearchData(array $data) : string
@@ -3,20 +3,21 @@
namespace App\Filament\Resources\DivisionResource\Pages;
use App\Filament\Resources\DivisionResource;
use App\Services\Filament\Traits\SeoGenerate;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Str;
class EditDivision extends EditRecord
{
use SeoGenerate;
protected static string $resource = DivisionResource::class;
protected array $seoData;
protected function mutateFormDataBeforeSave(array $data): array
{
$this->seoData = $this->generateSeo($data);
$data['search_data'] = $this->generateSearchData($data['description']);
return $data;
@@ -24,25 +25,11 @@ class EditDivision extends EditRecord
protected function afterSave(): void
{
$this->record->seo()->update($this->seoData);
$this->updateSeo($this->record);
}
private function generateSeo(array $data) : array
{
$title = $data['title'];
$rowData = $this->getFirstBlockByName('paragraph', $data['description']);
if ($rowData !== null) {
$description = strip_tags($rowData['data']['content']);
} else {
$description = null;
}
return [
'title' => $title,
'description' => Str::limit(htmlspecialchars($description, ENT_QUOTES, 'UTF-8'), 160),
];
}
private function getDataFromBlocks($block) : string
{