Commit 891abd7d authored by Mahmoud Aglan's avatar Mahmoud Aglan

Make public website the home page + add Website CMS to sidebar

- Route / now serves academy public website (no auth required)
- Dashboard moved to /dashboard
- Login/Dashboard button added to website navbar (desktop + mobile)
- Added "الموقع الإلكتروني" section to sidebar with all 9 CMS pages
- Added missing inventory items (POs, Kits, Stock Counts) to sidebar
- Configured explicit middleware redirects for guest/auth flows
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 97db5304
...@@ -19,6 +19,30 @@ public function __construct( ...@@ -19,6 +19,30 @@ public function __construct(
private WebsiteSettingService $settingService, private WebsiteSettingService $settingService,
) {} ) {}
public function home()
{
$academy = Academy::first();
if (!$academy) {
return redirect()->route('login');
}
$settings = $this->settingService->getOrCreate($academy);
app()->instance('current_academy', $academy);
app()->instance('website_settings', $settings);
$sections = $this->sectionService->getEnabled($academy);
$data = $this->gatherSectionData($academy, $sections);
return view('website.index', [
'academy' => $academy,
'settings' => $settings,
'sections' => $sections,
'data' => $data,
'showLoginButton' => true,
]);
}
public function show(string $slug) public function show(string $slug)
{ {
$academy = app('current_academy'); $academy = app('current_academy');
...@@ -33,6 +57,7 @@ public function show(string $slug) ...@@ -33,6 +57,7 @@ public function show(string $slug)
'settings' => $settings, 'settings' => $settings,
'sections' => $sections, 'sections' => $sections,
'data' => $data, 'data' => $data,
'showLoginButton' => true,
]); ]);
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
) )
->withMiddleware(function (Middleware $middleware): void { ->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*'); $middleware->trustProxies(at: '*');
$middleware->redirectGuestsTo('/login');
$middleware->redirectUsersTo('/dashboard');
$middleware->web(append: [ $middleware->web(append: [
\App\Http\Middleware\SetCurrentAcademy::class, \App\Http\Middleware\SetCurrentAcademy::class,
]); ]);
......
...@@ -57,6 +57,9 @@ ...@@ -57,6 +57,9 @@
['label' => 'المنتجات', 'route' => 'inventory.products', 'icon' => 'cube', 'permission' => 'inventory.list'], ['label' => 'المنتجات', 'route' => 'inventory.products', 'icon' => 'cube', 'permission' => 'inventory.list'],
['label' => 'المستودعات', 'route' => 'inventory.warehouses', 'icon' => 'building-storefront', 'permission' => 'inventory.list'], ['label' => 'المستودعات', 'route' => 'inventory.warehouses', 'icon' => 'building-storefront', 'permission' => 'inventory.list'],
['label' => 'الحركات', 'route' => 'inventory.movements', 'icon' => 'truck', 'permission' => 'inventory.list'], ['label' => 'الحركات', 'route' => 'inventory.movements', 'icon' => 'truck', 'permission' => 'inventory.list'],
['label' => 'أوامر الشراء', 'route' => 'inventory.purchase-orders', 'icon' => 'document', 'permission' => 'inventory.list'],
['label' => 'الأطقم', 'route' => 'inventory.kits', 'icon' => 'gift', 'permission' => 'inventory.list'],
['label' => 'جرد المخزون', 'route' => 'inventory.stock-counts', 'icon' => 'clipboard-document-list', 'permission' => 'inventory.list'],
['label' => 'التسويات', 'route' => 'inventory.adjustments', 'icon' => 'clipboard-document-list', 'permission' => 'inventory.adjust'], ['label' => 'التسويات', 'route' => 'inventory.adjustments', 'icon' => 'clipboard-document-list', 'permission' => 'inventory.adjust'],
]], ]],
...@@ -73,6 +76,18 @@ ...@@ -73,6 +76,18 @@
['label' => 'سجل الإرسال', 'route' => 'notifications.logs', 'icon' => 'eye', 'permission' => 'notifications.manage'], ['label' => 'سجل الإرسال', 'route' => 'notifications.logs', 'icon' => 'eye', 'permission' => 'notifications.manage'],
]], ]],
['section' => 'الموقع الإلكتروني', 'items' => [
['label' => 'أقسام الموقع', 'route' => 'website.manage.sections', 'icon' => 'grid', 'permission' => 'settings.manage'],
['label' => 'المظهر والألوان', 'route' => 'website.manage.theme', 'icon' => 'swatch', 'permission' => 'settings.manage'],
['label' => 'معرض الصور', 'route' => 'website.manage.gallery', 'icon' => 'photo', 'permission' => 'settings.manage'],
['label' => 'آراء العملاء', 'route' => 'website.manage.testimonials', 'icon' => 'chat', 'permission' => 'settings.manage'],
['label' => 'الأسئلة الشائعة', 'route' => 'website.manage.faqs', 'icon' => 'document-text', 'permission' => 'settings.manage'],
['label' => 'الأخبار', 'route' => 'website.manage.news', 'icon' => 'document', 'permission' => 'settings.manage'],
['label' => 'الشركاء', 'route' => 'website.manage.partners', 'icon' => 'building-library', 'permission' => 'settings.manage'],
['label' => 'رسائل التواصل', 'route' => 'website.manage.contacts', 'icon' => 'chat', 'permission' => 'settings.manage'],
['label' => 'معاينة الموقع', 'route' => 'website.manage.preview', 'icon' => 'eye', 'permission' => 'settings.manage'],
]],
['section' => 'الإدارة', 'items' => [ ['section' => 'الإدارة', 'items' => [
['label' => 'التقارير', 'route' => 'reports.view', 'icon' => 'chart-bar', 'permission' => 'reports.view'], ['label' => 'التقارير', 'route' => 'reports.view', 'icon' => 'chart-bar', 'permission' => 'reports.view'],
['label' => 'المستخدمين', 'route' => 'users.list', 'icon' => 'users', 'permission' => 'users.list'], ['label' => 'المستخدمين', 'route' => 'users.list', 'icon' => 'users', 'permission' => 'users.list'],
...@@ -125,6 +140,8 @@ ...@@ -125,6 +140,8 @@
'chat' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>', 'chat' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>',
'user' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>', 'user' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>',
'receipt-percent' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 14l6-6m-5.5.5h.01m4.99 5h.01M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16l3.5-2 3.5 2 3.5-2 3.5 2zM10 8.5a.5.5 0 11-1 0 .5.5 0 011 0zm5 5a.5.5 0 11-1 0 .5.5 0 011 0z"/>', 'receipt-percent' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 14l6-6m-5.5.5h.01m4.99 5h.01M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16l3.5-2 3.5 2 3.5-2 3.5 2zM10 8.5a.5.5 0 11-1 0 .5.5 0 011 0zm5 5a.5.5 0 11-1 0 .5.5 0 011 0z"/>',
'photo' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M3.75 21h16.5A2.25 2.25 0 0022.5 18.75V5.25A2.25 2.25 0 0020.25 3H3.75A2.25 2.25 0 001.5 5.25v13.5A2.25 2.25 0 003.75 21zm14.25-9.75a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z"/>',
'arrow-trending-up' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.25 18L9 11.25l4.306 4.307a11.95 11.95 0 015.814-5.519l2.74-1.22m0 0l-5.94-2.28m5.94 2.28l-2.28 5.941"/>',
'briefcase' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7H4a2 2 0 00-2 2v10a2 2 0 002 2h16a2 2 0 002-2V9a2 2 0 00-2-2zM16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"/>', 'briefcase' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7H4a2 2 0 00-2 2v10a2 2 0 002 2h16a2 2 0 002-2V9a2 2 0 00-2-2zM16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"/>',
]; ];
......
...@@ -21,7 +21,7 @@ class="px-3 py-2 text-sm font-medium text-white/80 hover:text-white rounded-lg h ...@@ -21,7 +21,7 @@ class="px-3 py-2 text-sm font-medium text-white/80 hover:text-white rounded-lg h
@endforeach @endforeach
</div> </div>
{{-- CTA + Mobile Toggle --}} {{-- CTA + Login + Mobile Toggle --}}
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
@php @php
$heroSection = $sections->firstWhere('section_key', \App\Domain\Website\Enums\SectionKey::Cta); $heroSection = $sections->firstWhere('section_key', \App\Domain\Website\Enums\SectionKey::Cta);
...@@ -31,6 +31,18 @@ class="px-3 py-2 text-sm font-medium text-white/80 hover:text-white rounded-lg h ...@@ -31,6 +31,18 @@ class="px-3 py-2 text-sm font-medium text-white/80 hover:text-white rounded-lg h
{{ $ctaText }} {{ $ctaText }}
</a> </a>
@auth
<a href="{{ route('dashboard') }}" class="hidden sm:inline-flex items-center gap-1 px-3 py-2 text-sm font-medium text-white/80 hover:text-white rounded-lg hover:bg-white/10 transition-all">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>
{{ __('لوحة التحكم') }}
</a>
@else
<a href="{{ route('login') }}" class="hidden sm:inline-flex items-center gap-1 px-3 py-2 text-sm font-medium text-white/80 hover:text-white rounded-lg hover:bg-white/10 transition-all">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"/></svg>
{{ __('تسجيل الدخول') }}
</a>
@endauth
{{-- Mobile Menu Button --}} {{-- Mobile Menu Button --}}
<button type="button" <button type="button"
class="lg:hidden p-2 rounded-lg text-white/80 hover:text-white hover:bg-white/10 transition-colors" class="lg:hidden p-2 rounded-lg text-white/80 hover:text-white hover:bg-white/10 transition-colors"
...@@ -54,6 +66,18 @@ class="block px-4 py-3 text-white/80 hover:text-white hover:bg-white/5 rounded-l ...@@ -54,6 +66,18 @@ class="block px-4 py-3 text-white/80 hover:text-white hover:bg-white/5 rounded-l
{{ $section->title ?? $section->section_key->label() }} {{ $section->title ?? $section->section_key->label() }}
</a> </a>
@endforeach @endforeach
<div class="border-t border-white/10 pt-3 mt-3">
@auth
<a href="{{ route('dashboard') }}" class="block px-4 py-3 text-white/80 hover:text-white hover:bg-white/5 rounded-lg transition-colors">
{{ __('لوحة التحكم') }}
</a>
@else
<a href="{{ route('login') }}" class="block px-4 py-3 text-white/80 hover:text-white hover:bg-white/5 rounded-lg transition-colors">
{{ __('تسجيل الدخول') }}
</a>
@endauth
</div>
</div> </div>
</div> </div>
</nav> </nav>
...@@ -86,7 +86,8 @@ ...@@ -86,7 +86,8 @@
Route::get('/pos-receipt/{uuid}', [PublicDocumentController::class, 'posReceipt'])->name('pos-receipt'); Route::get('/pos-receipt/{uuid}', [PublicDocumentController::class, 'posReceipt'])->name('pos-receipt');
}); });
// Public Academy Website (no auth, cached) // Public Academy Website — serves as home page
Route::get('/', [PublicWebsiteController::class, 'home'])->name('home');
Route::middleware(\App\Http\Middleware\ResolveAcademyFromSlug::class) Route::middleware(\App\Http\Middleware\ResolveAcademyFromSlug::class)
->prefix('site/{slug}') ->prefix('site/{slug}')
->name('website.') ->name('website.')
...@@ -115,7 +116,7 @@ ...@@ -115,7 +116,7 @@
->middleware('permission:settings.manage'); ->middleware('permission:settings.manage');
// Dashboard // Dashboard
Route::get('/', Dashboard::class)->name('dashboard'); Route::get('/dashboard', Dashboard::class)->name('dashboard');
// Profile // Profile
Route::get('/profile', \App\Livewire\Profile\UserProfile::class)->name('profile'); Route::get('/profile', \App\Livewire\Profile\UserProfile::class)->name('profile');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment