weizong song 3 years ago
parent ec4fb9b2b4
commit 11237a24f2

@ -13,10 +13,14 @@ use App\Models\Product;
use App\Models\ProductItems;
use App\Models\ProductParamedicLevel;
use App\Models\Recharge;
use App\Notifications\CustomerOrderCreated;
use App\Notifications\RechargePaid;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
class OrdersController extends CommonController
{
@ -428,6 +432,12 @@ class OrdersController extends CommonController
]);
$order->getSerial();
if ($order->prokect->managers) {
foreach ($order->prokect->managers as $manager) {
Notification::send($manager, new CustomerOrderCreated($order));
}
}
DB::commit();
return $this->getOrder($order->id);
} catch (\Exception $exception) {
@ -505,7 +515,7 @@ class OrdersController extends CommonController
public function cancelOrder($id)
{
$order = (new Orders())->with("orderItems")->find($id);
\Log::info($order);
Log::info($order);
if ($order->status !== Orders::STATUS_UNCONFIRMED) {
return response()->json([
"errorcode" => 50001,

@ -0,0 +1,65 @@
<?php
namespace App\Notifications;
use App\Models\Orders;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class CustomerOrderCreated extends Notification
{
use Queueable;
public $order;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Orders $order)
{
$this->order = $order;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
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.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
"order_id" => $this->order->id,
"order_serial" => $this->order->serial
];
}
}
Loading…
Cancel
Save