Skip to content

Commit

Permalink
Send notifications after order creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 17, 2024
1 parent 2abfc1c commit d1ea05d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/Livewire/OrderCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']);

Expand All @@ -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);
}

Expand Down

0 comments on commit d1ea05d

Please sign in to comment.