Skip to content

Commit f507593

Browse files
committed
Add SendVerificationDeliveryJob dispatch in ConfirmStatusDeliveryController
This commit enhances the confirmStatusDelivery method by dispatching the SendVerificationDeliveryJob after updating the delivery status. It also captures the feedback message when delivery is not confirmed, improving the notification process for delivery status changes.
1 parent 986dba5 commit f507593

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

app/Http/Controllers/Admin/Delivery/ConfirmStatusDeliveryController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@
77
use App\Models\FeedBack;
88
use Illuminate\Http\Request;
99
use App\Http\Controllers\Controller;
10+
use App\Jobs\SendVerificationDeliveryJob;
1011

1112
class ConfirmStatusDeliveryController extends Controller
1213
{
1314
public function confirmStatusDelivery($id,Request $request) {
1415

1516
try{
1617
$delivery = User::find($id);
17-
18+
$message='';
1819
if($request->isDelivery==0){
1920
$feedBack=new FeedBack;
2021
$feedBack->user_id=$delivery->id;
2122
$feedBack->message=$request->message;
2223
$feedBack->status=0;
2324
$feedBack->save();
25+
$message=$request->message;
2426
}
2527
$delivery->isDelivery = $request->isDelivery;
2628
$delivery->save();
29+
SendVerificationDeliveryJob::dispatch($delivery->id,$message);
2730
return response()->json(['message' => 'Status de livraison confirmé avec succès']);
2831
}catch (\Exception $e) {
2932
return response()->json([
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Jobs;
4+
5+
use App\Models\User;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Queue\SerializesModels;
8+
use Illuminate\Queue\InteractsWithQueue;
9+
use Illuminate\Contracts\Queue\ShouldQueue;
10+
use Illuminate\Foundation\Bus\Dispatchable;
11+
use App\Notifications\Seller\NewMessageFromVerificationNotification;
12+
13+
class SendVerificationDeliveryJob implements ShouldQueue
14+
{
15+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
16+
17+
/**
18+
* Create a new job instance.
19+
*/
20+
21+
protected $userId;
22+
protected $message;
23+
public function __construct($userId,$message)
24+
{
25+
$this->userId=$userId;
26+
$this->message=$message;
27+
}
28+
29+
/**
30+
* Execute the job.
31+
*/
32+
public function handle(): void
33+
{
34+
$user=User::find($this->userId);
35+
$user->notify(new NewMessageFromVerificationNotification($this->message));
36+
}
37+
}

0 commit comments

Comments
 (0)