feat: add GeneratesUniqueSlug class for unique slug generation
feat: create PostCategoryFactory for generating post category data feat: create PostFactory for generating post data feat: add retry_requested_at column to services table feat: add vcenter provisioning fields to products table feat: add module_host_id to os table feat: create email_notification_templates table for email templates feat: add scenario and format fields to template table feat: add admin fields to transactions table fix: update ticket table columns and types feat: add uuid to ticket table and backfill existing records fix: make ticket_reply user_id nullable feat: create notifications table for user notifications fix: make ticket uuid nullable feat: create post_categories table for blog categories feat: create posts table for blog posts feat: add invoice email template for PDF generation
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Customer;
|
||||
use App\Models\User;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'recipient_type',
|
||||
'recipient_id',
|
||||
'type',
|
||||
'title',
|
||||
'body',
|
||||
'link',
|
||||
'is_read',
|
||||
'read_at',
|
||||
'data',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_read' => 'boolean',
|
||||
'read_at' => 'datetime',
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
public static function notifyCustomer(Customer $customer, array $attributes): void
|
||||
{
|
||||
self::create([
|
||||
'recipient_type' => 'client',
|
||||
'recipient_id' => $customer->id,
|
||||
] + $attributes);
|
||||
}
|
||||
|
||||
public static function notifyAdmins(array $attributes): void
|
||||
{
|
||||
$adminIds = User::query()
|
||||
->whereHas('roles', fn ($query) => $query->where('guard_name', 'admin'))
|
||||
->pluck('id');
|
||||
|
||||
foreach ($adminIds as $adminId) {
|
||||
self::create([
|
||||
'recipient_type' => 'admin',
|
||||
'recipient_id' => $adminId,
|
||||
...$attributes,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user