Skip to content

Commit 095021d

Browse files
committed
Add message handling and job dispatch for seller confirmation in ConfirmStatusSellerController
This commit updates the ConfirmStatusSellerController to include a message variable that stores feedback for the user upon successful confirmation of a shop. It dispatches the SendVerificationSellerJob with the confirmation message when a shop is confirmed as a seller, enhancing user communication during the seller confirmation process.
1 parent c0c852b commit 095021d

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

app/Http/Controllers/Admin/Seller/ConfirmStatusSellerController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77
use App\Models\FeedBack;
88
use Illuminate\Http\Request;
99
use App\Http\Controllers\Controller;
10+
use App\Jobs\SendVerificationSellerJob;
1011

1112
class ConfirmStatusSellerController extends Controller
1213
{
1314
public function index($shop_id, Request $request) {
1415
try {
1516
$shop = Shop::find($shop_id);
16-
17+
$message='';
1718
if (!$shop) {
1819
return response()->json(['message' => 'Boutique non trouvée'], 404);
1920
}
2021
if($request->state=="2"){
2122
$feedBack=new FeedBack;
2223
$feedBack->user_id=$request->user_id;
2324
$feedBack->message=$request->message;
25+
$message=$request->message;
2426
$feedBack->status=0;
2527
$feedBack->save();
2628
}
@@ -31,8 +33,12 @@ public function index($shop_id, Request $request) {
3133
if ($shop->save()) {
3234
$user = User::find($shop->user_id);
3335
$user->isSeller = $request->isSeller;
36+
37+
if($request->isSeller == true){
38+
$message="Votre boutique".$shop->shop_name." a bien été confirmée avec succès";
39+
}
3440
$user->save();
35-
41+
SendVerificationSellerJob::dispatch($shop->id,$message);
3642
return response()->json(['message' => 'success']);
3743
}
3844

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\Shop;
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 SendVerificationSellerJob implements ShouldQueue
14+
{
15+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
16+
17+
/**
18+
* Create a new job instance.
19+
*/
20+
protected $shopId;
21+
protected $message;
22+
public function __construct($shopId,$message)
23+
{
24+
$this->shopId=$shopId;
25+
$this->message=$message;
26+
}
27+
28+
/**
29+
* Execute the job.
30+
*/
31+
public function handle(): void
32+
{
33+
$shop=Shop::find($this->shopId);
34+
$seller=$shop->user;
35+
$seller->notify(new NewMessageFromVerificationNotification($this->message));
36+
}
37+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace App\Notifications\Seller;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Notifications\Messages\MailMessage;
8+
use Illuminate\Notifications\Notification;
9+
10+
class NewMessageFromVerificationNotification extends Notification
11+
{
12+
use Queueable;
13+
14+
/**
15+
* Create a new notification instance.
16+
*/
17+
protected $message;
18+
public function __construct($message)
19+
{
20+
$this->message=$message;
21+
}
22+
23+
/**
24+
* Get the notification's delivery channels.
25+
*
26+
* @return array<int, string>
27+
*/
28+
public function via(object $notifiable): array
29+
{
30+
return ['database'];
31+
}
32+
33+
/**
34+
* Get the mail representation of the notification.
35+
*/
36+
public function toDatabase($notifiable)
37+
{
38+
return [
39+
'feedback' => $this->message,
40+
'message' => 'Vous aviez recu un nouveau message suite à la verification de votre boutique',
41+
];
42+
}
43+
44+
/**
45+
* Get the array representation of the notification.
46+
*
47+
* @return array<string, mixed>
48+
*/
49+
}

0 commit comments

Comments
 (0)