feat(cms): implement complete SysSiteCMS content management system
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
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Products\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Modules\Products\Models\ProductCategory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ProductCategoryController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$categories = ProductCategory::orderBy('order')->paginate(10);
|
||||
return view('products::admin.categories.index', compact('categories'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('products::admin.categories.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'slug' => 'required|string|max:255|unique:product_categories',
|
||||
'description' => 'nullable|string',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'active' => 'required|boolean',
|
||||
'order' => 'required|integer',
|
||||
]);
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$data['image'] = $request->file('image')->store('categories', 'public');
|
||||
}
|
||||
|
||||
ProductCategory::create($data);
|
||||
|
||||
return redirect()->route('admin.categories.index')->with('success', 'Categoria criada com sucesso.');
|
||||
}
|
||||
|
||||
public function edit(ProductCategory $category)
|
||||
{
|
||||
return view('products::admin.categories.edit', compact('category'));
|
||||
}
|
||||
|
||||
public function update(Request $request, ProductCategory $category)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'slug' => 'required|string|max:255|unique:product_categories,slug,' . $category->id,
|
||||
'description' => 'nullable|string',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'active' => 'required|boolean',
|
||||
'order' => 'required|integer',
|
||||
]);
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
if ($category->image) {
|
||||
Storage::disk('public')->delete($category->image);
|
||||
}
|
||||
$data['image'] = $request->file('image')->store('categories', 'public');
|
||||
}
|
||||
|
||||
$category->update($data);
|
||||
|
||||
return redirect()->route('admin.categories.index')->with('success', 'Categoria atualizada com sucesso.');
|
||||
}
|
||||
|
||||
public function destroy(ProductCategory $category)
|
||||
{
|
||||
if ($category->products()->count() > 0) {
|
||||
return redirect()->back()->with('error', 'Esta categoria possui produtos vinculados e não pode ser excluída.');
|
||||
}
|
||||
|
||||
if ($category->image) {
|
||||
Storage::disk('public')->delete($category->image);
|
||||
}
|
||||
|
||||
$category->delete();
|
||||
return redirect()->route('admin.categories.index')->with('success', 'Categoria excluída com sucesso.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Products\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Modules\Products\Models\Product;
|
||||
use App\Modules\Products\Models\ProductCategory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Models\User;
|
||||
use App\Modules\Products\Notifications\ProductActionNotification;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$products = Product::with('category')->latest()->paginate(10);
|
||||
return view('products::admin.products.index', compact('products'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$categories = ProductCategory::where('active', true)->orderBy('order')->get();
|
||||
return view('products::admin.products.create', compact('categories'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'category_id' => 'nullable|exists:product_categories,id',
|
||||
'name' => 'required|string|max:255',
|
||||
'slug' => 'required|string|max:255|unique:products',
|
||||
'description' => 'nullable|string',
|
||||
'price' => 'nullable|numeric',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'active' => 'required|boolean',
|
||||
]);
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$data['image'] = $request->file('image')->store('products', 'public');
|
||||
}
|
||||
|
||||
$product = Product::create($data);
|
||||
|
||||
// Notify administrators
|
||||
$admins = User::where('user_type', 'Admin')->get();
|
||||
Notification::send($admins, new ProductActionNotification($product, Auth::user(), 'created'));
|
||||
|
||||
return redirect()->route('admin.products.index')->with('success', 'Produto criado com sucesso.');
|
||||
}
|
||||
|
||||
public function edit(Product $product)
|
||||
{
|
||||
$categories = ProductCategory::where('active', true)->orderBy('order')->get();
|
||||
return view('products::admin.products.edit', compact('product', 'categories'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Product $product)
|
||||
{
|
||||
$request->validate([
|
||||
'category_id' => 'nullable|exists:product_categories,id',
|
||||
'name' => 'required|string|max:255',
|
||||
'slug' => 'required|string|max:255|unique:products,slug,' . $product->id,
|
||||
'description' => 'nullable|string',
|
||||
'price' => 'nullable|numeric',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'active' => 'required|boolean',
|
||||
]);
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
if ($product->image) {
|
||||
Storage::disk('public')->delete($product->image);
|
||||
}
|
||||
$data['image'] = $request->file('image')->store('products', 'public');
|
||||
}
|
||||
|
||||
$product->update($data);
|
||||
|
||||
// Notify administrators
|
||||
$admins = User::where('user_type', 'Admin')->get();
|
||||
Notification::send($admins, new ProductActionNotification($product, Auth::user(), 'updated'));
|
||||
|
||||
return redirect()->route('admin.products.index')->with('success', 'Produto atualizado com sucesso.');
|
||||
}
|
||||
|
||||
public function destroy(Product $product)
|
||||
{
|
||||
if ($product->image) {
|
||||
Storage::disk('public')->delete($product->image);
|
||||
}
|
||||
$product->delete();
|
||||
return redirect()->route('admin.products.index')->with('success', 'Produto excluído com sucesso.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Products\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Page;
|
||||
use App\Modules\Products\Models\Product;
|
||||
use App\Modules\Products\Models\ProductCategory;
|
||||
|
||||
class ProductPageController extends Controller
|
||||
{
|
||||
public function produtos(Request $request)
|
||||
{
|
||||
$page = Page::where('slug', 'produtos')->where('active', true)->firstOrFail();
|
||||
|
||||
$categories = ProductCategory::where('active', true)
|
||||
->whereHas('products', function ($q) {
|
||||
$q->where('active', true);
|
||||
})
|
||||
->orderBy('order')
|
||||
->get();
|
||||
|
||||
$query = Product::where('active', true);
|
||||
|
||||
if ($request->has('categoria') && $request->categoria != '') {
|
||||
$query->whereHas('category', function ($q) use ($request) {
|
||||
$q->where('slug', $request->categoria);
|
||||
});
|
||||
}
|
||||
|
||||
$products = $query->latest()->get();
|
||||
|
||||
$currentCategory = null;
|
||||
if ($request->has('categoria') && $request->categoria != '') {
|
||||
$currentCategory = ProductCategory::where('slug', $request->categoria)->firstOrFail();
|
||||
}
|
||||
|
||||
return view('products::produtos', compact('page', 'products', 'categories', 'currentCategory'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user