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:
marco
2026-09-07 19:06:53 -03:00
commit 38295e7e88
279 changed files with 33691 additions and 0 deletions
@@ -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'));
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Modules\Products\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Product extends Model
{
protected $fillable = ['category_id', 'name', 'slug', 'description', 'price', 'image', 'active'];
public function category(): BelongsTo
{
return $this->belongsTo(ProductCategory::class, 'category_id');
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Modules\Products\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ProductCategory extends Model
{
protected $fillable = ['name', 'slug', 'description', 'image', 'active', 'order'];
public function products(): HasMany
{
return $this->hasMany(Product::class, 'category_id');
}
}
@@ -0,0 +1,88 @@
<?php
namespace App\Modules\Products\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Modules\Products\Models\Product;
use App\Models\User;
class ProductActionNotification extends Notification
{
use Queueable;
protected $product;
protected $user;
protected $action; // 'created' or 'updated'
/**
* Create a new notification instance.
*/
public function __construct(Product $product, User $user, string $action)
{
$this->product = $product;
$this->user = $user;
$this->action = $action;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
$channels = [];
$prefs = $notifiable->preferences ?? [];
// If admin wants to receive product change notifications
if ($prefs['notifications_product_actions'] ?? true) {
if ($prefs['notifications_email'] ?? true) {
$channels[] = 'mail';
}
if ($prefs['notifications_system'] ?? true) {
$channels[] = 'database';
}
}
return $channels;
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
$actionText = $this->action === 'created' ? 'criado' : 'atualizado';
return (new MailMessage)
->subject('Produto ' . ucfirst($actionText) . ' - ' . config('app.name'))
->greeting('Olá, ' . $notifiable->name)
->line('Um produto do site foi ' . $actionText . ' por ' . $this->user->name . '.')
->line('**Nome do Produto:** ' . $this->product->name)
->line('**Preço:** R$ ' . number_format($this->product->price, 2, ',', '.'))
->action('Gerenciar Produtos', route('admin.products.index'))
->line('Obrigado por usar nosso sistema!');
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
$actionText = $this->action === 'created' ? 'criado' : 'atualizado';
return [
'product_id' => $this->product->id,
'name' => $this->user->name,
'email' => $this->user->email,
'action' => $this->action,
'message' => "Produto '{$this->product->name}' foi {$actionText}.",
'link' => route('admin.products.edit', $this->product->id)
];
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Modules\Products\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Route;
/**
* Products Module Service Provider
*
* Registers all Products module resources when the module is enabled:
* - Routes (public and admin)
* - Views (namespaced as 'products::')
*/
class ProductsServiceProvider extends ServiceProvider
{
/**
* The module identifier.
*/
protected string $moduleName = 'products';
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// Register module views
$this->loadViewsFrom(
__DIR__ . '/../resources/views',
'products'
);
// Register module routes
Route::middleware(['web'])
->group(__DIR__ . '/../routes/web.php');
}
}
@@ -0,0 +1,102 @@
@extends('layouts.admin')
@section('title', 'Nova Categoria')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Nova Categoria</h1>
<a href="{{ route('admin.categories.index') }}" class="btn btn-sm btn-secondary shadow-sm">
<i class="bi bi-arrow-left text-white-50"></i> Voltar
</a>
</div>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Informações da Categoria</h6>
</div>
<div class="card-body">
<form action="{{ route('admin.categories.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="row">
<div class="col-md-8">
<div class="form-group mb-3">
<label class="font-weight-bold">Nome da Categoria</label>
<input type="text" name="name" id="name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name') }}" required>
@error('name') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Slug (URL)</label>
<input type="text" name="slug" id="slug" class="form-control @error('slug') is-invalid @enderror" value="{{ old('slug') }}" required>
@error('slug') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Descrição</label>
<textarea name="description" id="editor" class="form-control @error('description') is-invalid @enderror" rows="5">{{ old('description') }}</textarea>
@error('description') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
</div>
<div class="col-md-4">
<div class="form-group mb-3">
<label class="font-weight-bold">Imagem da Categoria</label>
<input type="file" name="image" class="form-control-file @error('image') is-invalid @enderror">
@error('image') <div class="invalid-feedback d-block">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Ordem</label>
<input type="number" name="order" class="form-control @error('order') is-invalid @enderror" value="{{ old('order', 0) }}" required>
@error('order') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Status</label>
<select name="active" class="form-control">
<option value="1" {{ old('active', '1') == '1' ? 'selected' : '' }}>Ativa</option>
<option value="0" {{ old('active') == '0' ? 'selected' : '' }}>Inativa</option>
</select>
</div>
</div>
</div>
<hr>
<button type="submit" class="btn btn-primary btn-block py-3 fw-bold shadow-sm">
<i class="bi bi-floppy me-1"></i> Salvar Categoria
</button>
</form>
</div>
</div>
@endsection
@push('css')
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">
@endpush
@push('js')
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>
<script>
$(document).ready(function() {
$('#editor').summernote({
height: 200,
tabsize: 2,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['view', ['fullscreen', 'codeview']]
]
});
document.getElementById('name').addEventListener('keyup', function() {
let text = this.value.toLowerCase()
.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '-');
document.getElementById('slug').value = text;
});
});
</script>
@endpush
@@ -0,0 +1,109 @@
@extends('layouts.admin')
@section('title', 'Editar Categoria')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Editar Categoria: {{ $category->name }}</h1>
<a href="{{ route('admin.categories.index') }}" class="btn btn-sm btn-secondary shadow-sm">
<i class="bi bi-arrow-left text-white-50"></i> Voltar
</a>
</div>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Informações da Categoria</h6>
</div>
<div class="card-body">
<form action="{{ route('admin.categories.update', $category) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="row">
<div class="col-md-8">
<div class="form-group mb-3">
<label class="font-weight-bold">Nome da Categoria</label>
<input type="text" name="name" id="name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name', $category->name) }}" required>
@error('name') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Slug (URL)</label>
<input type="text" name="slug" id="slug" class="form-control @error('slug') is-invalid @enderror" value="{{ old('slug', $category->slug) }}" required>
@error('slug') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Descrição</label>
<textarea name="description" id="editor" class="form-control @error('description') is-invalid @enderror" rows="5">{{ old('description', $category->description) }}</textarea>
@error('description') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
</div>
<div class="col-md-4">
<div class="form-group mb-3">
<label class="font-weight-bold">Imagem da Categoria</label>
@if($category->image)
<div class="mb-2">
<img src="{{ asset('storage/' . $category->image) }}" class="img-thumbnail" style="height: 100px;">
</div>
@endif
<input type="file" name="image" class="form-control-file @error('image') is-invalid @enderror">
<small class="text-muted">Deixe em branco para manter a imagem atual.</small>
@error('image') <div class="invalid-feedback d-block">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Ordem</label>
<input type="number" name="order" class="form-control @error('order') is-invalid @enderror" value="{{ old('order', $category->order) }}" required>
@error('order') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Status</label>
<select name="active" class="form-control">
<option value="1" {{ old('active', $category->active) == '1' ? 'selected' : '' }}>Ativa</option>
<option value="0" {{ old('active', $category->active) == '0' ? 'selected' : '' }}>Inativa</option>
</select>
</div>
</div>
</div>
<hr>
<button type="submit" class="btn btn-primary btn-block py-3 fw-bold shadow-sm">
<i class="bi bi-floppy me-1"></i> Salvar Alterações
</button>
</form>
</div>
</div>
@endsection
@push('css')
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">
@endpush
@push('js')
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>
<script>
$(document).ready(function() {
$('#editor').summernote({
height: 200,
tabsize: 2,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['view', ['fullscreen', 'codeview']]
]
});
document.getElementById('name').addEventListener('keyup', function() {
let text = this.value.toLowerCase()
.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '-');
document.getElementById('slug').value = text;
});
});
</script>
@endpush
@@ -0,0 +1,78 @@
@extends('layouts.admin')
@section('title', 'Categorias de Produtos')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Categorias de Produtos</h1>
<a href="{{ route('admin.categories.create') }}" class="btn btn-sm btn-primary shadow-sm">
<i class="bi bi-plus-lg text-white-50"></i> Nova Categoria
</a>
</div>
@if(session('success'))
<div class="alert alert-success border-0 shadow-sm mb-4">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="alert alert-danger border-0 shadow-sm mb-4">{{ session('error') }}</div>
@endif
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Lista de Categorias</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th width="50">Ordem</th>
<th width="100">Imagem</th>
<th>Nome</th>
<th>Slug</th>
<th>Status</th>
<th width="150">Ações</th>
</tr>
</thead>
<tbody>
@foreach($categories as $category)
<tr>
<td>{{ $category->order }}</td>
<td>
@if($category->image)
<img src="{{ asset('storage/' . $category->image) }}" class="img-thumbnail" style="height: 50px;">
@else
<span class="badge badge-light">Sem foto</span>
@endif
</td>
<td>{{ $category->name }}</td>
<td>{{ $category->slug }}</td>
<td>
<span class="badge badge-{{ $category->active ? 'success' : 'secondary' }}">
{{ $category->active ? 'Ativa' : 'Inativa' }}
</span>
</td>
<td>
<a href="{{ route('admin.categories.edit', $category) }}" class="btn btn-sm btn-primary">
<i class="bi bi-pencil"></i>
</a>
<form action="{{ route('admin.categories.destroy', $category) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Excluir esta categoria? Certifique-se de que não há produtos vinculados.')">
<i class="bi bi-trash"></i>
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="mt-4">
{{ $categories->links() }}
</div>
</div>
</div>
@endsection
@@ -0,0 +1,116 @@
@extends('layouts.admin')
@section('title', 'Novo Produto')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Novo Produto</h1>
<a href="{{ route('admin.products.index') }}" class="btn btn-sm btn-secondary shadow-sm">
<i class="bi bi-arrow-left text-white-50"></i> Voltar
</a>
</div>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Informações do Produto</h6>
</div>
<div class="card-body">
<form action="{{ route('admin.products.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="row">
<div class="col-md-8">
<div class="form-group mb-3">
<label class="font-weight-bold">Nome do Produto</label>
<input type="text" name="name" id="name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name') }}" required>
@error('name') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Slug (URL)</label>
<input type="text" name="slug" id="slug" class="form-control @error('slug') is-invalid @enderror" value="{{ old('slug') }}" required>
@error('slug') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Descrição</label>
<textarea name="description" id="editor" class="form-control @error('description') is-invalid @enderror" rows="10">{{ old('description') }}</textarea>
@error('description') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
</div>
<div class="col-md-4">
<div class="form-group mb-3">
<label class="font-weight-bold">Categoria</label>
<select name="category_id" class="form-control @error('category_id') is-invalid @enderror">
<option value="">Sem Categoria</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id') == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Preço (R$)</label>
<input type="number" name="price" step="0.01" class="form-control @error('price') is-invalid @enderror" value="{{ old('price') }}">
@error('price') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Imagem do Produto</label>
<input type="file" name="image" class="form-control-file @error('image') is-invalid @enderror">
@error('image') <div class="invalid-feedback d-block">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Status</label>
<select name="active" class="form-control">
<option value="1" {{ old('active', '1') == '1' ? 'selected' : '' }}>Ativo</option>
<option value="0" {{ old('active') == '0' ? 'selected' : '' }}>Inativo</option>
</select>
</div>
</div>
</div>
<hr>
<button type="submit" class="btn btn-primary btn-block py-3 fw-bold shadow-sm">
<i class="bi bi-floppy me-1"></i> Salvar Produto
</button>
</form>
</div>
</div>
@endsection
@push('css')
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">
@endpush
@push('js')
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>
<script>
$(document).ready(function() {
$('#editor').summernote({
height: 300,
tabsize: 2,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['view', ['fullscreen', 'codeview']]
]
});
document.getElementById('name').addEventListener('keyup', function() {
let text = this.value.toLowerCase()
.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '-');
document.getElementById('slug').value = text;
});
});
</script>
@endpush
@@ -0,0 +1,123 @@
@extends('layouts.admin')
@section('title', 'Editar Produto')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Editar Produto: {{ $product->name }}</h1>
<a href="{{ route('admin.products.index') }}" class="btn btn-sm btn-secondary shadow-sm">
<i class="bi bi-arrow-left text-white-50"></i> Voltar
</a>
</div>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Informações do Produto</h6>
</div>
<div class="card-body">
<form action="{{ route('admin.products.update', $product) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="row">
<div class="col-md-8">
<div class="form-group mb-3">
<label class="font-weight-bold">Nome do Produto</label>
<input type="text" name="name" id="name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name', $product->name) }}" required>
@error('name') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Slug (URL)</label>
<input type="text" name="slug" id="slug" class="form-control @error('slug') is-invalid @enderror" value="{{ old('slug', $product->slug) }}" required>
@error('slug') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Descrição</label>
<textarea name="description" id="editor" class="form-control @error('description') is-invalid @enderror" rows="10">{{ old('description', $product->description) }}</textarea>
@error('description') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
</div>
<div class="col-md-4">
<div class="form-group mb-3">
<label class="font-weight-bold">Categoria</label>
<select name="category_id" class="form-control @error('category_id') is-invalid @enderror">
<option value="">Sem Categoria</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id', $product->category_id) == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Preço (R$)</label>
<input type="number" name="price" step="0.01" class="form-control @error('price') is-invalid @enderror" value="{{ old('price', $product->price) }}">
@error('price') <div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Imagem do Produto</label>
@if($product->image)
<div class="mb-2">
<img src="{{ asset('storage/' . $product->image) }}" class="img-thumbnail" style="height: 100px;">
</div>
@endif
<input type="file" name="image" class="form-control-file @error('image') is-invalid @enderror">
<small class="text-muted">Deixe em branco para manter a imagem atual.</small>
@error('image') <div class="invalid-feedback d-block">{{ $message }}</div> @enderror
</div>
<div class="form-group mb-3">
<label class="font-weight-bold">Status</label>
<select name="active" class="form-control">
<option value="1" {{ old('active', $product->active) == '1' ? 'selected' : '' }}>Ativo</option>
<option value="0" {{ old('active', $product->active) == '0' ? 'selected' : '' }}>Inativo</option>
</select>
</div>
</div>
</div>
<hr>
<button type="submit" class="btn btn-primary btn-block py-3 fw-bold shadow-sm">
<i class="bi bi-floppy me-1"></i> Salvar Alterações
</button>
</form>
</div>
</div>
@endsection
@push('css')
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">
@endpush
@push('js')
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>
<script>
$(document).ready(function() {
$('#editor').summernote({
height: 300,
tabsize: 2,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['view', ['fullscreen', 'codeview']]
]
});
document.getElementById('name').addEventListener('keyup', function() {
let text = this.value.toLowerCase()
.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '-');
document.getElementById('slug').value = text;
});
});
</script>
@endpush
@@ -0,0 +1,80 @@
@extends('layouts.admin')
@section('title', 'Gerenciar Produtos')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Gerenciamento de Produtos</h1>
<a href="{{ route('admin.products.create') }}" class="btn btn-sm btn-primary shadow-sm">
<i class="bi bi-plus-lg text-white-50"></i> Novo Produto
</a>
</div>
@if(session('success'))
<div class="alert alert-success border-0 shadow-sm mb-4">{{ session('success') }}</div>
@endif
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Lista de Produtos</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th width="100">Imagem</th>
<th>Nome</th>
<th>Categoria</th>
<th>Preço</th>
<th>Status</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
@foreach($products as $product)
<tr>
<td>
@if($product->image)
<img src="{{ asset('storage/' . $product->image) }}" class="img-thumbnail" style="height: 50px;">
@else
<span class="badge badge-light">Sem foto</span>
@endif
</td>
<td>{{ $product->name }}</td>
<td>
@if($product->category)
<span class="badge badge-info">{{ $product->category->name }}</span>
@else
<span class="badge badge-light">Sem Categoria</span>
@endif
</td>
<td>R$ {{ number_format($product->price, 2, ',', '.') }}</td>
<td>
<span class="badge badge-{{ $product->active ? 'success' : 'secondary' }}">
{{ $product->active ? 'Ativo' : 'Inativo' }}
</span>
</td>
<td>
<a href="{{ route('admin.products.edit', $product) }}" class="btn btn-sm btn-primary">
<i class="bi bi-pencil"></i>
</a>
<form action="{{ route('admin.products.destroy', $product) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Excluir este produto?')">
<i class="bi bi-trash"></i>
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="mt-4">
{{ $products->links() }}
</div>
</div>
</div>
@endsection
+147
View File
@@ -0,0 +1,147 @@
@extends('layouts.app')
@section('title', $page->title)
@section('meta_description', $page->meta_description)
@section('meta_keywords', $page->meta_keywords)
@section('og_title', $page->og_title)
@section('og_description', $page->og_description)
@section('og_image', $page->og_image)
@section('canonical', $page->canonical_url)
@section('content')
<div class="container py-5">
<div class="text-center mb-5">
<h1 class="display-4 fw-bold text-primary">{{ $page->title }}</h1>
<div class="lead text-muted">{!! $page->content !!}</div>
</div>
<!-- Filtro de Categorias -->
@if($categories->count() > 0)
<div class="row mb-5">
<div class="col-12 text-center">
<div class="d-flex flex-wrap justify-content-center gap-2">
<a href="{{ route('produtos') }}" class="btn btn-{{ !request()->has('categoria') || request()->categoria == '' ? 'primary' : 'outline-primary' }} rounded-pill px-4">
Todos
</a>
@foreach($categories as $category)
<a href="{{ route('produtos', ['categoria' => $category->slug]) }}" class="btn btn-{{ request()->categoria == $category->slug ? 'primary' : 'outline-primary' }} rounded-pill px-4">
{{ $category->name }}
</a>
@endforeach
</div>
</div>
</div>
@endif
<!-- Detalhes da Categoria Atual -->
@if($currentCategory)
<div class="row mb-5 align-items-center">
@if($currentCategory->image)
<div class="col-md-4">
<img src="{{ asset('storage/' . $currentCategory->image) }}" class="img-fluid rounded shadow-sm" alt="{{ $currentCategory->name }}">
</div>
@endif
<div class="{{ $currentCategory->image ? 'col-md-8' : 'col-12 text-center' }}">
<h2 class="fw-bold text-dark">{{ $currentCategory->name }}</h2>
@if($currentCategory->description)
<div class="text-muted lead">{!! $currentCategory->description !!}</div>
@endif
</div>
</div>
@endif
<div class="row g-4">
@forelse($products as $product)
<div class="col-md-4 col-lg-3">
<div class="card h-100 border-0 shadow-sm overflow-hidden product-card">
<div class="position-relative">
@if($product->image)
<img src="{{ asset('storage/' . $product->image) }}" class="card-img-top" alt="{{ $product->name }}" style="height: 250px; object-fit: cover;">
@else
<div class="bg-light d-flex align-items-center justify-content-center" style="height: 250px;">
<i class="bi bi-box-seam display-1 text-muted"></i>
</div>
@endif
@if($product->price)
<div class="position-absolute bottom-0 end-0 bg-primary text-white px-3 py-2 fw-bold rounded-start-pill shadow">
R$ {{ number_format($product->price, 2, ',', '.') }}
</div>
@endif
</div>
<div class="card-body p-4">
<h5 class="card-title fw-bold text-dark mb-3">{{ $product->name }}</h5>
<div class="card-text text-muted small mb-4">
{!! Str::limit(strip_tags($product->description), 100) !!}
</div>
<div class="d-grid">
<button class="btn btn-outline-primary rounded-pill fw-bold" data-bs-toggle="modal" data-bs-target="#productModal{{ $product->id }}">
<i class="bi bi-info-circle me-1"></i> Detalhes
</button>
</div>
</div>
</div>
</div>
<!-- Modal de Detalhes do Produto -->
<div class="modal fade" id="productModal{{ $product->id }}" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content border-0 shadow-lg rounded-4 overflow-hidden">
<div class="modal-body p-0">
<div class="row g-0">
<div class="col-lg-6">
@if($product->image)
<img src="{{ asset('storage/' . $product->image) }}" class="img-fluid h-100" style="object-fit: cover; min-height: 400px;">
@else
<div class="bg-light d-flex align-items-center justify-content-center h-100" style="min-height: 400px;">
<i class="bi bi-box-seam display-1 text-muted"></i>
</div>
@endif
</div>
<div class="col-lg-6 p-5">
<button type="button" class="btn-close float-end" data-bs-dismiss="modal" aria-label="Close"></button>
<h2 class="fw-bold text-primary mb-3">{{ $product->name }}</h2>
@if($product->price)
<h3 class="text-dark fw-bold mb-4">R$ {{ number_format($product->price, 2, ',', '.') }}</h3>
@endif
<div class="text-muted mb-5">
{!! $product->description !!}
</div>
<div class="d-grid gap-3">
<a href="https://wa.me/{{ preg_replace('/\D/', '', $company->phone) }}?text=Olá! Gostaria de mais informações sobre o produto: {{ $product->name }}" target="_blank" class="btn btn-success btn-lg rounded-pill fw-bold">
<i class="bi bi-whatsapp me-2"></i> Tenho Interesse
</a>
<a href="{{ route('contato') }}" class="btn btn-outline-primary btn-lg rounded-pill fw-bold">
Solicitar Orçamento
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@empty
<div class="col-12 text-center py-5">
<i class="bi bi-box-seam fs-1 text-muted d-block mb-3"></i>
<p class="text-muted lead">Nenhum produto cadastrado no momento.</p>
</div>
@endforelse
</div>
</div>
@endsection
@push('css')
<style>
.product-card {
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.product-card:hover {
transform: translateY(-10px);
box-shadow: 0 1rem 3rem rgba(0,0,0,.1) !important;
}
.rounded-start-pill {
border-top-left-radius: 50px;
border-bottom-left-radius: 50px;
}
</style>
@endpush
+39
View File
@@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Modules\Products\Http\Controllers\ProductPageController;
use App\Modules\Products\Http\Controllers\Admin\ProductController;
use App\Modules\Products\Http\Controllers\Admin\ProductCategoryController;
/*
|--------------------------------------------------------------------------
| Products Module - Public Routes
|--------------------------------------------------------------------------
*/
Route::get('/produtos', [ProductPageController::class, 'produtos'])->name('produtos');
/*
|--------------------------------------------------------------------------
| Products Module - Admin Routes
|--------------------------------------------------------------------------
*/
Route::middleware(['auth', 'verified'])->prefix('admin')->name('admin.')->group(function () {
// Products management (permission: products)
Route::middleware('permission:products')->group(function () {
Route::get('/produtos/categorias', [ProductCategoryController::class, 'index'])->name('categories.index');
Route::get('/produtos/categorias/criar', [ProductCategoryController::class, 'create'])->name('categories.create');
Route::post('/produtos/categorias', [ProductCategoryController::class, 'store'])->name('categories.store');
Route::get('/produtos/categorias/{category}/editar', [ProductCategoryController::class, 'edit'])->name('categories.edit');
Route::put('/produtos/categorias/{category}', [ProductCategoryController::class, 'update'])->name('categories.update');
Route::delete('/produtos/categorias/{category}', [ProductCategoryController::class, 'destroy'])->name('categories.destroy');
Route::get('/produtos', [ProductController::class, 'index'])->name('products.index');
Route::get('/produtos/criar', [ProductController::class, 'create'])->name('products.create');
Route::post('/produtos', [ProductController::class, 'store'])->name('products.store');
Route::get('/produtos/{product}/editar', [ProductController::class, 'edit'])->name('products.edit');
Route::put('/produtos/{product}', [ProductController::class, 'update'])->name('products.update');
Route::delete('/produtos/{product}', [ProductController::class, 'destroy'])->name('products.destroy');
});
});