diff --git a/app/Livewire/OrderCreate.php b/app/Livewire/OrderCreate.php index 4d10db8..74442ba 100644 --- a/app/Livewire/OrderCreate.php +++ b/app/Livewire/OrderCreate.php @@ -2,7 +2,11 @@ namespace App\Livewire; +use App\Models\User; +use App\Notifications\OrderCreatedForUser; +use App\Notifications\OrderCreatedForWriter; use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Notification; use Illuminate\View\View; use Livewire\Attributes\Validate; use Livewire\Component; @@ -87,7 +91,11 @@ public function createOrder(): Redirector | RedirectResponse } // Send notification to the user + $order->user->notify(new OrderCreatedForUser($order)); + // Send notification to all writers + $writers = User::where('role', 'writer')->get(); + Notification::send($writers, new OrderCreatedForWriter($order)); $this->reset(['title', 'description', 'total_price']); @@ -105,8 +113,8 @@ public function removeAttachment($name): void if (count($this->attachments) === $initialCount) { dd('Attachment not found'); } - //Convert the collection back to an array + //Convert the collection back to an array $this->attachments = array_values($this->attachments); }