أعمالي ابنِ مشروع SaaS المقالات
لايف واير

بناء الإشعارات مع Livewire v4

February 01, 2026 1 دقيقة قراءة 56 مشاهدة

ابنِ نظام إشعارات.

مكون Toast

@php
new class extends Livewire\Component {
    public array $notifications = [];
    
    #[On('notify')]
    public function add(string $message, string $type = 'info'): void
    {
        $this->notifications[] = ['id' => uniqid(), 'message' => $message, 'type' => $type];
    }
    
    public function remove(string $id): void
    {
        $this->notifications = array_filter($this->notifications, fn($n) => $n['id'] !== $id);
    }
}
@endphp

التشغيل

$this->dispatch('notify', message: 'تم الحفظ!', type: 'success');
شارك هذه المقالة:

مقالات ذات صلة

التعليقات (0)

يرجى تسجيل الدخول لترك تعليق. تسجيل الدخول

لا توجد تعليقات بعد. كن أول من يعلق!