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
99 lines
2.8 KiB
PHP
Executable File
99 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use App\Models\News;
|
|
use App\Models\User;
|
|
|
|
class NewsActionNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
protected $news;
|
|
protected $user;
|
|
protected $action; // 'created', 'updated', 'photo_added', 'photo_deleted'
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public function __construct(News $news, User $user, string $action)
|
|
{
|
|
$this->news = $news;
|
|
$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 ($prefs['notifications_system'] ?? true) {
|
|
$channels[] = 'database';
|
|
}
|
|
if ($prefs['notifications_email'] ?? true) {
|
|
$channels[] = 'mail';
|
|
}
|
|
|
|
return $channels;
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*/
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$actionMap = [
|
|
'created' => 'criada',
|
|
'updated' => 'atualizada',
|
|
'photo_added' => 'com nova imagem adicionada',
|
|
'photo_deleted' => 'com imagem removida',
|
|
];
|
|
|
|
$actionText = $actionMap[$this->action] ?? 'modificada';
|
|
|
|
return (new MailMessage)
|
|
->subject('Notícia ' . ucfirst($actionText) . ' - ' . config('app.name'))
|
|
->greeting('Olá, ' . $notifiable->name)
|
|
->line('Uma notícia foi ' . $actionText . ' por ' . $this->user->name . '.')
|
|
->line('**Título:** ' . $this->news->title)
|
|
->action('Gerenciar Notícias', route('admin.news.index'))
|
|
->line('Obrigado por usar nosso sistema!');
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
$actionMap = [
|
|
'created' => 'criada',
|
|
'updated' => 'atualizada',
|
|
'photo_added' => 'imagem adicionada',
|
|
'photo_deleted' => 'imagem removida',
|
|
];
|
|
|
|
$actionText = $actionMap[$this->action] ?? 'modificada';
|
|
|
|
return [
|
|
'news_id' => $this->news->id,
|
|
'name' => $this->user->name,
|
|
'email' => $this->user->email,
|
|
'action' => $this->action,
|
|
'message' => "Notícia '{$this->news->title}': {$actionText}.",
|
|
'link' => route('admin.news.edit', $this->news->id)
|
|
];
|
|
}
|
|
}
|