Initial implementation of the HomeSysPanel CMS built with Laravel 13.0. Includes complete admin panel, content management, user authentication, modular architecture for products/services/chatbot, and marketing tools. Key features: - User authentication with email verification and password reset - Role-based access control (Admin/User with granular permissions) - Content management (pages, news, FAQ, downloads, galleries, banners) - Contact management system with subjects and responses - Marketing tools (email campaigns, visitor analytics, social sharing) - Modular architecture (Products, Services, Chatbot modules) - AI Chatbot integration with OpenRouter.ai and LlamaCpp support - Visitor tracking with geolocation - SEO optimization with meta tags and Open Graph - Responsive design with Bootstrap 5 - Dark mode support - Maintenance mode - Feature request system
92 lines
3.1 KiB
PHP
Executable File
92 lines
3.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Page;
|
|
use App\Models\User;
|
|
use App\Notifications\PageActionNotification;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Illuminate\Support\Str;
|
|
|
|
class PageController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$pages = Page::latest()->paginate(10);
|
|
return view('admin.pages.index', compact('pages'));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('admin.pages.create');
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$validated = $request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'slug' => 'required|string|max:255|unique:pages',
|
|
'content' => 'nullable|string',
|
|
'meta_description' => 'nullable|string|max:255',
|
|
'meta_keywords' => 'nullable|string|max:255',
|
|
'og_title' => 'nullable|string|max:255',
|
|
'og_description' => 'nullable|string|max:255',
|
|
'og_image' => 'nullable|string|max:255',
|
|
'canonical_url' => 'nullable|string|max:255',
|
|
'active' => 'required|boolean',
|
|
]);
|
|
|
|
$page = Page::create($validated);
|
|
|
|
/** @var \App\Models\User $user */
|
|
$user = Auth::user();
|
|
|
|
// Notificar outros administradores sobre a nova página
|
|
$admins = User::where('user_type', 'Admin')->where('id', '!=', $user->id)->get();
|
|
Notification::send($admins, new PageActionNotification($page, $user, 'created'));
|
|
|
|
return redirect()->route('admin.pages.index')->with('success', 'Página criada com sucesso.');
|
|
}
|
|
|
|
public function edit(Page $page)
|
|
{
|
|
return view('admin.pages.edit', compact('page'));
|
|
}
|
|
|
|
public function update(Request $request, Page $page)
|
|
{
|
|
$validated = $request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'slug' => 'required|string|max:255|unique:pages,slug,' . $page->id,
|
|
'content' => 'nullable|string',
|
|
'meta_description' => 'nullable|string|max:255',
|
|
'meta_keywords' => 'nullable|string|max:255',
|
|
'og_title' => 'nullable|string|max:255',
|
|
'og_description' => 'nullable|string|max:255',
|
|
'og_image' => 'nullable|string|max:255',
|
|
'canonical_url' => 'nullable|string|max:255',
|
|
'active' => 'required|boolean',
|
|
]);
|
|
|
|
$page->update($validated);
|
|
|
|
/** @var \App\Models\User $user */
|
|
$user = Auth::user();
|
|
|
|
// Notificar outros administradores sobre a atualização
|
|
$admins = User::where('user_type', 'Admin')->where('id', '!=', $user->id)->get();
|
|
Notification::send($admins, new PageActionNotification($page, $user, 'updated'));
|
|
|
|
return redirect()->route('admin.pages.index')->with('success', 'Página atualizada com sucesso.');
|
|
}
|
|
|
|
public function destroy(Page $page)
|
|
{
|
|
$page->delete();
|
|
return redirect()->route('admin.pages.index')->with('success', 'Página excluída com sucesso.');
|
|
}
|
|
}
|