This commit is contained in:
F4ilji
2025-05-06 10:47:12 +05:00
parent 6f4da2e704
commit 8dadd19adc
7 changed files with 55 additions and 40 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ class DivisionResource extends Resource
Tabs\Tab::make('Контент') Tabs\Tab::make('Контент')
->icon('heroicon-o-document-text') ->icon('heroicon-o-document-text')
->schema([ ->schema([
ContentBuilderItem::getItem('content') ContentBuilderItem::getItem('description')
]), ]),
]), ]),
]), ]),
@@ -38,32 +38,6 @@ class CreateDivision extends CreateRecord
return strtolower($result); return strtolower($result);
} }
private function getFirstBlockByName(string $name, array $content) : array|null
{
$data = null;
foreach ($content as $block) {
$data = ($block['type'] === $name) ? $block : null;
break;
}
return $data;
}
private function getBlockBySeoActiveState(string $name, array $content) : array|null
{
$data = [];
foreach ($content as $block) {
if ($block['type'] === $name) {
$data[] = $block;
}
}
$block = null;
foreach ($data as $item) {
if ($item['data']['seo_active'] === true) {
$block = $item;
}
}
return $block;
}
private function getDataFromBlocks($block) : string private function getDataFromBlocks($block) : string
{ {
@@ -2,9 +2,10 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Ship\Requests\Request;
use Closure; use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
class EnsureUserIsSuperadmin class EnsureUserIsSuperadmin
@@ -16,9 +17,10 @@ class EnsureUserIsSuperadmin
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, Closure $next)
{ {
// Проверяем, что пользователь аутентифицирован и имеет роль superadmin
if (!Auth::check() || !Auth::user()->hasRole('super_admin')) { if (!Auth::check() || !Auth::user()->hasRole('super_admin')) {
return response('Access denied. You do not have permission to access this route.', 403); return Inertia::render('Error', ['status' => 403])
->toResponse($request)
->setStatusCode(403);
} }
return $next($request); return $next($request);
+7 -1
View File
@@ -2,10 +2,11 @@
namespace App\Models; namespace App\Models;
use App\Services\App\Seo\SeoDescriptionInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Division extends Model class Division extends Model implements SeoDescriptionInterface
{ {
use HasFactory; use HasFactory;
@@ -24,4 +25,9 @@ class Division extends Model
{ {
return $this->belongsToMany(User::class, 'division_user')->withPivot(['administrativePosition', 'sort', 'service_email', 'service_phone', 'cabinet']); return $this->belongsToMany(User::class, 'division_user')->withPivot(['administrativePosition', 'sort', 'service_email', 'service_phone', 'cabinet']);
} }
public function getSeoDescription(): array
{
return $this->description;
}
} }
@@ -7,11 +7,27 @@
</svg> </svg>
<span class="sr-only">Previous</span> <span class="sr-only">Previous</span>
</a> </a>
<div class="flex items-center gap-x-1"> <div class="flex items-center gap-x-1">
<a v-for="link in getPageLinks(links)" :href="link.url" <!-- Десктопная версия - показываем все страницы -->
:class="link.active ? 'border-gray-200 text-gray-800' : 'border-transparent hover:bg-gray-100'" <template v-for="link in getPageLinks(links)" :key="link.label">
class="min-h-9.5 min-w-9.5 flex justify-center items-center border py-2 px-3 text-sm rounded-lg focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">{{ link.label }}</a> <a :href="link.url"
:class="link.active ? 'border-gray-200 text-gray-800' : 'border-transparent hover:bg-gray-100'"
class="hidden md:flex min-h-9.5 min-w-9.5 justify-center items-center border py-2 px-3 text-sm rounded-lg focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">
{{ link.label }}
</a>
</template>
<!-- Мобильная версия - показываем только активную и соседние страницы -->
<template v-for="link in getMobilePageLinks(links)" :key="'mobile-' + link.label">
<a :href="link.url"
:class="link.active ? 'border-gray-200 text-gray-800' : 'border-transparent hover:bg-gray-100'"
class="md:hidden min-h-9.5 min-w-9.5 flex justify-center items-center border py-2 px-3 text-sm rounded-lg focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">
{{ link.label }}
</a>
</template>
</div> </div>
<a :href="links.links.slice(-1).pop().url" class="min-h-9.5 min-w-9.5 py-2 px-2.5 inline-flex justify-center items-center gap-x-2 text-sm rounded-lg border border-transparent text-gray-800 hover:bg-gray-100 focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none" aria-label="Next"> <a :href="links.links.slice(-1).pop().url" class="min-h-9.5 min-w-9.5 py-2 px-2.5 inline-flex justify-center items-center gap-x-2 text-sm rounded-lg border border-transparent text-gray-800 hover:bg-gray-100 focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none" aria-label="Next">
<span class="sr-only">Next</span> <span class="sr-only">Next</span>
<svg class="shrink-0 size-3.5" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <svg class="shrink-0 size-3.5" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@@ -39,6 +55,20 @@ export default {
link.label !== 'pagination.previous' && link.label !== 'pagination.previous' &&
link.label !== 'pagination.next' link.label !== 'pagination.next'
); );
},
getMobilePageLinks(pagination) {
const allLinks = this.getPageLinks(pagination);
const activeIndex = allLinks.findIndex(link => link.active);
// Возвращаем только активную страницу и соседние
if (activeIndex === -1) return allLinks;
const start = Math.max(0, activeIndex - 1);
const end = Math.min(allLinks.length - 1, activeIndex + 1);
return allLinks.slice(start, end + 1);
} }
} }
}; };
+8 -5
View File
@@ -1,12 +1,10 @@
import '../css/app.css'; import '../css/app.css';
import { createInertiaApp } from '@inertiajs/vue3' import { createInertiaApp } from '@inertiajs/vue3'
import createServer from '@inertiajs/vue3/server' import createServer from '@inertiajs/vue3/server'
import { renderToString } from '@vue/server-renderer' import { renderToString } from '@vue/server-renderer'
import { createSSRApp, h } from 'vue' import { createSSRApp, h } from 'vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m'; import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
createServer(page => createServer(page =>
createInertiaApp({ createInertiaApp({
page, page,
@@ -16,9 +14,14 @@ createServer(page =>
return pages[`./Pages/${name}.vue`]() return pages[`./Pages/${name}.vue`]()
}, },
setup({ App, props, plugin }) { setup({ App, props, plugin }) {
return createSSRApp({ const ssrApp = createSSRApp({
render: () => h(App, props), render: () => h(App, props),
}) });
ssrApp.config.errorHandler = () => null;
ssrApp.config.warnHandler = () => null;
return ssrApp
.use(plugin) .use(plugin)
.use(ZiggyVue, { .use(ZiggyVue, {
...page.props.ziggy, ...page.props.ziggy,
@@ -26,4 +29,4 @@ createServer(page =>
}); });
}, },
}), }),
) );
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
{{-- <title inertia>{{ config('app.name', 'Laravel') }}</title>--}} {{-- <title inertia>{{ config('app.name', 'Laravel') }}</title>--}}