Skip to content

Commit

Permalink
Created notifications for order creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 17, 2024
1 parent ce8f668 commit ae36d0d
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/Livewire/OrderCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public function createOrder(): Redirector | RedirectResponse
}
}

// Send notification to the user
// Send notification to all writers

$this->reset(['title', 'description', 'total_price']);

return redirect()->route('orders.pay', ['orderId' => $order->id])->with('success', 'Order created successfully.');
Expand Down
54 changes: 54 additions & 0 deletions app/Notifications/OrderCreatedForUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class OrderCreatedForUser extends Notification
{
use Queueable;

/**
* Create a new notification instance.
*/
public function __construct()
{
//
}

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}

/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
54 changes: 54 additions & 0 deletions app/Notifications/OrderCreatedForWriter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class OrderCreatedForWriter extends Notification
{
use Queueable;

/**
* Create a new notification instance.
*/
public function __construct()
{
//
}

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}

/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}

0 comments on commit ae36d0d

Please sign in to comment.