ifnex/04_Laravel/app/Notifications/ShipmentUpdatedNotification.php
Kazem Alghasi e9a0c731c2 feat(admin): implement currency management and rate import system
Introduce a new currency management module including a dedicated
resource, database migration, and a custom Filament page for importing
exchange rates. Additionally, enhance the ShipmentResource table with
improved column visibility, sorting, and route display, and integrate
shipment update notifications.
2026-08-24 01:18:34 +03:30

45 lines
1.4 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Shipment;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notifiable;
class ShipmentUpdatedNotification
{
public static function notify(Shipment $shipment): void
{
$changes = $shipment->getChanges();
$ignored = ['updated_at'];
$changedFields = array_filter(
array_keys($changes),
fn ($key) => !in_array($key, $ignored)
);
if (empty($changedFields)) {
return;
}
$fieldList = implode('، ', $changedFields);
$label = count($changedFields) === 1 ? $changedFields[0] : count($changedFields) . ' فیلد';
Notification::make()
->title('محموله ویرایش شد')
->body("AWB {$shipment->awb_no}{$label} تغییر کرد: {$fieldList}")
->info()
->icon('heroicon-o-pencil-square')
->actions([
Action::make('view')
->label('مشاهده')
->url(
\Filament\Facades\Filament::getPanel()->getResourceUrl(Shipment::class) . '/' . $shipment->id,
shouldOpenInNewTab: false
),
])
->sendToDatabase(\App\Models\User::all());
}
}