Changes
This commit is contained in:
@@ -5,56 +5,17 @@ namespace App\Filament\Components\Forms;
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Filament\Components\Forms\ItemForm\Pages\ContentBuilderItem;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Components\Tab;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use TomatoPHP\FilamentIcons\Components\IconPicker;
|
||||
|
||||
class PageForm
|
||||
{
|
||||
|
||||
public static function getPageTemplates() {
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files()->in('../resources/js/Pages/Client/BasePageTemplate');
|
||||
|
||||
|
||||
$fileInfos = [];
|
||||
foreach ($finder as $fileInfo) {
|
||||
$fileInfos[] = [
|
||||
'filename' => $fileInfo->getBasename('.' . $fileInfo->getExtension()),
|
||||
|
||||
'path' => preg_replace('/.*\/(Client\/.*)/', '$1', $fileInfo->getPath() . '/' . $fileInfo->getBasename('.' . $fileInfo->getExtension())),
|
||||
'extension' => $fileInfo->getExtension(),
|
||||
'size' => $fileInfo->getSize(),
|
||||
'mtime' => $fileInfo->getMTime(),
|
||||
'atime' => $fileInfo->getATime(),
|
||||
'isReadable' => $fileInfo->isReadable(),
|
||||
'isWritable' => $fileInfo->isWritable(),
|
||||
];
|
||||
}
|
||||
$fileInfos = collect($fileInfos);
|
||||
return $fileInfos->pluck('filename', 'path');
|
||||
|
||||
}
|
||||
|
||||
public static function getForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -92,13 +53,34 @@ class PageForm
|
||||
'500' => 'Ведутся технические работы',
|
||||
])->label('Статус')->required()->default('200'),
|
||||
Toggle::make('searchable')->default(true)->label('Индексируется поиском')->inline(false),
|
||||
IconPicker::make('icon')
|
||||
->default('heroicon-o-academic-cap')
|
||||
->label('Icon'),
|
||||
|
||||
|
||||
TextInput::make('search_data')->hidden(),
|
||||
]),
|
||||
Forms\Components\Tabs\Tab::make('Контент')->schema([
|
||||
ContentBuilderItem::getItem('content')
|
||||
]),
|
||||
Forms\Components\Tabs\Tab::make('Настройки')->schema([
|
||||
Select::make('template')->label('Шаблон')->options(self::getPageTemplates())->required(),
|
||||
Section::make()->schema([
|
||||
Toggle::make('settings.hide_page_sub_section_links')
|
||||
->label('Скрыть сайдбар смежных страниц')
|
||||
->columnSpan(1),
|
||||
|
||||
Toggle::make('settings.hide_page_navigate_links')
|
||||
->label('Скрыть навигацию по страницу')
|
||||
->columnSpan(1),
|
||||
|
||||
Toggle::make('settings.hide_breadcrumbs')
|
||||
->label('Скрыть хлебные крошки')
|
||||
->columnSpan(1),
|
||||
//
|
||||
// Toggle::make('settings.full_width_page')
|
||||
// ->label('Страница на всю ширину')
|
||||
// ->columnSpan(1)->default(true),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ class EditPage extends EditRecord
|
||||
|
||||
protected array $seoData;
|
||||
|
||||
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$this->seoData = $this->generateSeo($data);
|
||||
|
||||
@@ -60,7 +60,7 @@ class PageController extends Controller
|
||||
abort($error);
|
||||
}
|
||||
|
||||
return Inertia::render($page->template, compact('page', 'subSectionPages', 'breadcrumbs', 'seo'));
|
||||
return Inertia::render('Page', compact('page', 'subSectionPages', 'breadcrumbs', 'seo'));
|
||||
}
|
||||
public function getRegisteredPages()
|
||||
{
|
||||
@@ -78,74 +78,4 @@ class PageController extends Controller
|
||||
];
|
||||
return Inertia::render('AdminPanel/Pages/Registered', compact('pages', 'filters'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$pages = PageResource::collection(Page::query()
|
||||
->when(request()->input('search'), function ($query, $search) {
|
||||
$query->where('title', 'like', "%{$search}%");
|
||||
})
|
||||
->where('is_registered', false)
|
||||
->orderBy('id', 'desc')
|
||||
->paginate(request()->input('perPage', 9))
|
||||
->withQueryString());
|
||||
$filters = [
|
||||
'search' => request()->input('search'),
|
||||
];
|
||||
return Inertia::render('AdminPanel/Pages/Index', compact('pages', 'filters'));
|
||||
}
|
||||
|
||||
public function edit($slug)
|
||||
{
|
||||
$page = new PageResource(Page::where('slug', '=', $slug)->first());
|
||||
return Inertia::render('AdminPanel/Pages/Edit', compact('page'));
|
||||
}
|
||||
|
||||
public function update(Page $page, UpdateRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['content'] = json_encode($data['content']);
|
||||
$page->update($data);
|
||||
return redirect()->route('admin.page.index');
|
||||
}
|
||||
|
||||
public function editRegisteredPage($id)
|
||||
{
|
||||
$page = new RegisteredPageResource(Page::find($id));
|
||||
return Inertia::render('AdminPanel/Pages/EditRegisteredPage', compact('page'));
|
||||
}
|
||||
|
||||
public function updateRegisteredPage($id, Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'title' => 'required',
|
||||
'path' => 'required',
|
||||
'is_visible' => 'required',
|
||||
'code' => 'required'
|
||||
]);
|
||||
$page = Page::find($id);
|
||||
$page->update($data);
|
||||
return redirect()->route('admin.registered.page.index');
|
||||
}
|
||||
|
||||
public function destroy(Page $page)
|
||||
{
|
||||
$page->delete();
|
||||
return redirect()->route('admin.page.index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return Inertia::render('AdminPanel/Pages/Create');
|
||||
}
|
||||
|
||||
public function store(StoreRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['content'] = json_encode($data['content']);
|
||||
Page::create($data);
|
||||
return redirect()->route('admin.page.index');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class ClientPageNavigateResource extends JsonResource
|
||||
'slug' => $this->slug,
|
||||
'path' => $this->path,
|
||||
'is_url' => $this->is_url,
|
||||
'icon' => $this->icon
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ class PageResource extends JsonResource
|
||||
'code' => $this->code,
|
||||
'path' => $this->path,
|
||||
'is_url' => $this->is_url,
|
||||
'settings' => $this->settings,
|
||||
'icon' => $this->icon,
|
||||
'section' => $this->section ? $this->section->title : null,
|
||||
'created_at' => $this->created_at->diffforhumans()
|
||||
];
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ApplicantQuestion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AuthorPost extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
protected $table = 'authors_posts';
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ExternalVacancy extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LibraryNews extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
public function seo()
|
||||
{
|
||||
return $this->morphOne(Seo::class, 'seoable');
|
||||
}
|
||||
|
||||
protected $casts = [
|
||||
'content' => 'array',
|
||||
];
|
||||
}
|
||||
@@ -25,6 +25,7 @@ class Page extends Model
|
||||
|
||||
protected $casts = [
|
||||
'content' => 'array',
|
||||
'settings' => 'array',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Author extends Model
|
||||
class Slide extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -5,18 +5,19 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VirtualExhibition extends Model
|
||||
class Slider extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
protected $casts = [
|
||||
'content' => 'array'
|
||||
'settings' => 'array',
|
||||
'image' => 'array',
|
||||
];
|
||||
|
||||
public function seo()
|
||||
public function slidable()
|
||||
{
|
||||
return $this->morphOne(Seo::class, 'seoable');
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Student extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VacantPosition extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user