From f38148cca365bb62c4f9c9698ef804877299a130 Mon Sep 17 00:00:00 2001 From: joddyabott Date: Tue, 19 Aug 2025 16:09:25 +0330 Subject: [PATCH 1/2] write event for harim --- .../ConfirmGuaranteeLetterNeedProcessed.php | 17 +++++++ .../ConfirmNoRoadAccessNeedProcessed.php | 17 +++++++ .../ConfirmRoadAccessEditNeedProcessed.php | 23 +++++++++ .../Harim/ConfirmRoadAccessNeedProcessed.php | 20 ++++++++ .../Harim/RejectRequestProcessed.php | 35 +++++++++++++ .../Harim/GeneralManagerController.php | 10 ++++ .../Harim/SendConfirmGuaranteeLetterNeed.php | 36 +++++++++++++ .../Harim/SendConfirmNoRoadAccessEditNeed.php | 39 ++++++++++++++ .../Harim/SendConfirmNoRoadAccessNeed.php | 39 ++++++++++++++ .../Harim/SendConfirmRoadAccessNeed.php | 47 +++++++++++++++++ .../Harim/SendRejectNotification.php | 51 +++++++++++++++++++ 11 files changed, 334 insertions(+) create mode 100644 app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php create mode 100644 app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedProcessed.php create mode 100644 app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedProcessed.php create mode 100644 app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedProcessed.php create mode 100644 app/Events/V3/Dashboard/Harim/RejectRequestProcessed.php create mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php create mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php create mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php create mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php create mode 100644 app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php diff --git a/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php b/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php new file mode 100644 index 00000000..ee92536f --- /dev/null +++ b/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php @@ -0,0 +1,17 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('channel-name'), + ]; + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php b/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php index 04c1ad76..5e75f7a0 100644 --- a/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php +++ b/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php @@ -4,6 +4,10 @@ namespace App\Http\Controllers\V3\Dashboard\Harim; use App\Enums\HarimAction; use App\Enums\HarimStates; +use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedProcessed; +use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedProcessed; +use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedProcessed; +use App\Events\V3\Dashboard\Harim\RejectRequestProcessed; use App\Facades\DataTable\DataTableFacade; use App\Http\Controllers\Controller; use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmRoadAccessEditNeedRequest; @@ -57,6 +61,7 @@ class GeneralManagerController extends Controller 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); + RejectRequestProcessed::dispatch($request->harim_id); }); return $this->successResponse(); } @@ -125,6 +130,7 @@ class GeneralManagerController extends Controller 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); + ConfirmRoadAccessNeedProcessed::dispatch($request->harim_id); }); return $this->successResponse(); } @@ -147,6 +153,8 @@ class GeneralManagerController extends Controller 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); + ConfirmNoRoadAccessNeedProcessed::dispatch($request->harim_id); + }); return $this->successResponse(); } @@ -169,6 +177,7 @@ class GeneralManagerController extends Controller 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); + ConfirmRoadAccessEditNeedRequest::dispatch($request->harim_id); }); return $this->successResponse(); } @@ -191,6 +200,7 @@ class GeneralManagerController extends Controller 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); + ConfirmGuaranteeLetterNeedProcessed::dispatch($request->harim_id); }); return $this->successResponse(); } diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php new file mode 100644 index 00000000..861f9670 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php @@ -0,0 +1,36 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + public function handle(ConfirmGuaranteeLetterNeedProcessed $event): void + { + // + } + public function subscribe(Dispatcher $events) + { + $events->listen( + ConfirmGuaranteeLetterNeedProcessed::class, + SendConfirmGuaranteeLetterNeed::class, + ); + } + +} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php new file mode 100644 index 00000000..437d655c --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php @@ -0,0 +1,39 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + public function handle(ConfirmRoadAccessEditNeedProcessed $event): void + { + // + } + + public function subscribe(Dispatcher $events) + { + $events->listen( + ConfirmRoadAccessEditNeedProcessed::class, + SendConfirmNoRoadAccessEditNeed::class, + ); + } + +} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php new file mode 100644 index 00000000..2fe8a514 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php @@ -0,0 +1,39 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + public function handle(ConfirmNoRoadAccessNeedProcessed $event): void + { + // + } + + public function subscribe(Dispatcher $events) + { + $events->listen( + ConfirmNoRoadAccessNeedProcessed::class, + SendConfirmNoRoadAccessNeed::class, + ); + + } + +} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php new file mode 100644 index 00000000..d5bf4cb3 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php @@ -0,0 +1,47 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + + } + + /** + * Handle the event. + */ + public function handle(ConfirmRoadAccessNeedProcessed $event): void + { + Http::post($this->url, + array( + 'username' => $this->username, + 'password' => $this->password, + 'harim_id' => $this->harimId, + 'status' => 'rejected', + 'message' => $this->message, + ))->throw(); + } + public function subscribe(Dispatcher $events) + { + $events->listen( + ConfirmRoadAccessNeedProcessed::class , + SendConfirmRoadAccessNeed::class, + ); + + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php b/app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php new file mode 100644 index 00000000..37b6b025 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php @@ -0,0 +1,51 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + /** + * @throws RequestException + */ + public function handle(RejectRequestProcessed $event): void + { + Http::post($this->url, + array( + 'username' => $this->username, + 'password' => $this->password, + 'harim_id' => $this->harimId, + 'status' => 'need road access', + 'panjareh_vahed_id' => $this->panjareh_vahed_id, + 'date' => now(), + 'single choice' => 'accepted', + + ))->throw(); + } + + public function subscribe(Dispatcher $events) + { + $events->listen( + RejectRequestProcessed::class, + SendRejectNotification::class, 'handle' + ); + + } +} From d50f5b41c3f5b22100e81cb1ec0c3ffa1e48f272 Mon Sep 17 00:00:00 2001 From: joddyabott Date: Wed, 20 Aug 2025 15:20:00 +0330 Subject: [PATCH 2/2] fix code event --- ...hp => ConfirmGuaranteeLetterNeedEvent.php} | 3 +- ...d.php => ConfirmNoRoadAccessNeedEvent.php} | 3 +- ...php => ConfirmRoadAccessEditNeedEvent.php} | 4 +- ...sed.php => ConfirmRoadAccessNeedEvent.php} | 7 +-- .../V3/Dashboard/Harim/RejectRequestEvent.php | 18 ++++++ .../Harim/RejectRequestProcessed.php | 35 ----------- .../Harim/GeneralManagerController.php | 63 ++++++++++++++----- .../ConfirmGuaranteeLetterNeedListener.php | 33 ++++++++++ .../Harim/ConfirmNoRoadAccessNeedListener.php | 34 ++++++++++ .../ConfirmRoadAccessEditNeedListener.php | 34 ++++++++++ .../Harim/ConfirmRoadAccessNeedListener.php | 37 +++++++++++ .../Dashboard/Harim/RejectRequestListener.php | 38 +++++++++++ .../Harim/SendConfirmGuaranteeLetterNeed.php | 36 ----------- .../Harim/SendConfirmNoRoadAccessEditNeed.php | 39 ------------ .../Harim/SendConfirmNoRoadAccessNeed.php | 39 ------------ .../Harim/SendConfirmRoadAccessNeed.php | 47 -------------- .../Harim/SendRejectNotification.php | 51 --------------- app/Providers/EventServiceProvider.php | 26 ++++++++ 18 files changed, 271 insertions(+), 276 deletions(-) rename app/Events/V3/Dashboard/Harim/{ConfirmNoRoadAccessNeedProcessed.php => ConfirmGuaranteeLetterNeedEvent.php} (90%) rename app/Events/V3/Dashboard/Harim/{ConfirmGuaranteeLetterNeedProcessed.php => ConfirmNoRoadAccessNeedEvent.php} (89%) rename app/Events/V3/Dashboard/Harim/{ConfirmRoadAccessNeedProcessed.php => ConfirmRoadAccessEditNeedEvent.php} (76%) rename app/Events/V3/Dashboard/Harim/{ConfirmRoadAccessEditNeedProcessed.php => ConfirmRoadAccessNeedEvent.php} (63%) create mode 100644 app/Events/V3/Dashboard/Harim/RejectRequestEvent.php delete mode 100644 app/Events/V3/Dashboard/Harim/RejectRequestProcessed.php create mode 100644 app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php create mode 100644 app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php create mode 100644 app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php create mode 100644 app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php create mode 100644 app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php delete mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php delete mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php delete mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php delete mode 100644 app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php delete mode 100644 app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php diff --git a/app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedProcessed.php b/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedEvent.php similarity index 90% rename from app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedProcessed.php rename to app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedEvent.php index 0d765740..aaa7fc04 100644 --- a/app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedProcessed.php +++ b/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedEvent.php @@ -8,10 +8,9 @@ use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -class ConfirmNoRoadAccessNeedProcessed +class ConfirmGuaranteeLetterNeedEvent { use Dispatchable, InteractsWithSockets, SerializesModels; public function __construct(public Harim $harim){} - } diff --git a/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php b/app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedEvent.php similarity index 89% rename from app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php rename to app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedEvent.php index ee92536f..af50405a 100644 --- a/app/Events/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedProcessed.php +++ b/app/Events/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedEvent.php @@ -8,10 +8,9 @@ use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -class ConfirmGuaranteeLetterNeedProcessed +class ConfirmNoRoadAccessNeedEvent { use Dispatchable, InteractsWithSockets, SerializesModels; public function __construct(public Harim $harim){} - } diff --git a/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedProcessed.php b/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedEvent.php similarity index 76% rename from app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedProcessed.php rename to app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedEvent.php index 051edb63..85d59df8 100644 --- a/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedProcessed.php +++ b/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedEvent.php @@ -3,13 +3,11 @@ namespace App\Events\V3\Dashboard\Harim; use App\Models\Harim; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -class ConfirmRoadAccessNeedProcessed +class ConfirmRoadAccessEditNeedEvent { use Dispatchable, InteractsWithSockets, SerializesModels; diff --git a/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedProcessed.php b/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedEvent.php similarity index 63% rename from app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedProcessed.php rename to app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedEvent.php index a479e720..85bd15fe 100644 --- a/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedProcessed.php +++ b/app/Events/V3/Dashboard/Harim/ConfirmRoadAccessNeedEvent.php @@ -3,15 +3,11 @@ namespace App\Events\V3\Dashboard\Harim; use App\Models\Harim; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; -use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -class ConfirmRoadAccessEditNeedProcessed +class ConfirmRoadAccessNeedEvent { use Dispatchable, InteractsWithSockets, SerializesModels; @@ -19,5 +15,4 @@ class ConfirmRoadAccessEditNeedProcessed * Create a new event instance. */ public function __construct(public Harim $harim){} - } diff --git a/app/Events/V3/Dashboard/Harim/RejectRequestEvent.php b/app/Events/V3/Dashboard/Harim/RejectRequestEvent.php new file mode 100644 index 00000000..9bfc458e --- /dev/null +++ b/app/Events/V3/Dashboard/Harim/RejectRequestEvent.php @@ -0,0 +1,18 @@ + - */ - public function broadcastOn(): array - { - return [ - new PrivateChannel('channel-name'), - ]; - } -} diff --git a/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php b/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php index 5e75f7a0..56a45151 100644 --- a/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php +++ b/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php @@ -4,10 +4,11 @@ namespace App\Http\Controllers\V3\Dashboard\Harim; use App\Enums\HarimAction; use App\Enums\HarimStates; -use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedProcessed; -use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedProcessed; -use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedProcessed; -use App\Events\V3\Dashboard\Harim\RejectRequestProcessed; +use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedEvent; +use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedEvent; +use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedEvent; +use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent; +use App\Events\V3\Dashboard\Harim\RejectRequestEvent; use App\Facades\DataTable\DataTableFacade; use App\Http\Controllers\Controller; use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmRoadAccessEditNeedRequest; @@ -44,8 +45,10 @@ class GeneralManagerController extends Controller public function rejectRequest(RejectRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ 'expert_id' => auth()->user()->id, 'previous_state_id' => $harim->state_id, @@ -61,15 +64,19 @@ class GeneralManagerController extends Controller 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); - RejectRequestProcessed::dispatch($request->harim_id); + + RejectRequestEvent::dispatch($harim); }); + return $this->successResponse(); } public function referRequest(ReferRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::REFER->value; + $harim->histories()->create([ 'expert_id'=> auth()->user()->id, 'previous-state_id' => $harim->state_id, @@ -86,13 +93,16 @@ class GeneralManagerController extends Controller 'state_name' => HarimStates::name($state), ]); }); + return $this->successResponse(); } public function referFile(ReferFileRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::REFER->value; + $harim->histories()->create([ 'expert_id'=> auth()->user()->id, 'previous-state_id' => $harim->state_id, @@ -109,13 +119,16 @@ class GeneralManagerController extends Controller 'state_name' => HarimStates::name($state), ]); }); + return $this->successResponse(); } public function confirmRoadAccessNeed(ConfirmRoadAccessNeedRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ 'expert_id' => auth()->user()->id, 'previous_state_id' => $harim->state_id, @@ -126,19 +139,24 @@ class GeneralManagerController extends Controller ]); $state = HarimStates::ERSAL_BE_PANJAREH_VAHED_NIAZ_BE_RAH_DASTRASI->value; + $harim->update([ 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); - ConfirmRoadAccessNeedProcessed::dispatch($request->harim_id); + + ConfirmRoadAccessNeedEvent::dispatch($harim); }); + return $this->successResponse(); } public function confirmNoRoadAccessNeed(ConfirmNoRoadAccessNeedRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ 'expert_id' => auth()->user()->id, 'previous_state_id' => $harim->state_id, @@ -149,20 +167,25 @@ class GeneralManagerController extends Controller ]); $state = HarimStates::ERSAL_BE_PANJAREH_VAHED_BEDONEH_NIAZ_BE_RAH_DASTRASI->value; + $harim->update([ 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); - ConfirmNoRoadAccessNeedProcessed::dispatch($request->harim_id); + + ConfirmNoRoadAccessNeedEvent::dispatch($harim); }); + return $this->successResponse(); } public function confirmRoadAccessEditNeed(ConfirmRoadAccessEditNeedRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ 'expert_id' => auth()->user()->id, 'previous_state_id' => $harim->state_id, @@ -173,19 +196,24 @@ class GeneralManagerController extends Controller ]); $state = HarimStates::UPDATE_FILE_BARGOZARE_SHODE->value; + $harim->update([ 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); - ConfirmRoadAccessEditNeedRequest::dispatch($request->harim_id); + + ConfirmRoadAccessEditNeedEvent::dispatch($harim); }); + return $this->successResponse(); } public function confirmGuaranteeLetterNeed(ConfirmGuaranteeLetterNeedRequest $request, Harim $harim): JsonResponse { - DB::transaction(function () use ($request, $harim) { + DB::transaction(function () use ($request, $harim) + { $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ 'expert_id' => auth()->user()->id, 'previous_state_id' => $harim->state_id, @@ -196,12 +224,15 @@ class GeneralManagerController extends Controller ]); $state = HarimStates::ERSAL_ZEMANAT_NAME_TAVASOTE_KARBAR->value; + $harim->update([ 'state_id' => $state, 'state_name' => HarimStates::name($state), ]); - ConfirmGuaranteeLetterNeedProcessed::dispatch($request->harim_id); + + ConfirmGuaranteeLetterNeedEvent::dispatch($harim); }); + return $this->successResponse(); } public function show(ShowRequest $request, Harim $harim): JsonResponse diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php new file mode 100644 index 00000000..6f9839b8 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php @@ -0,0 +1,33 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + public function handle(ConfirmGuaranteeLetterNeedEvent $event): void + { + Http::post($this->url, + array( + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + ' ' => $event->harim->id, + ))->throw(); + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php new file mode 100644 index 00000000..ce5bc75e --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php @@ -0,0 +1,34 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + public function handle(ConfirmNoRoadAccessNeedEvent $event): void + { + Http::post($this->url, + array( + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + ))->throw(); + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php new file mode 100644 index 00000000..b0a84311 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php @@ -0,0 +1,34 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + public function handle(ConfirmRoadAccessEditNeedEvent $event): void + { + Http::post($this->url, + array( + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + ))->throw(); + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php new file mode 100644 index 00000000..eb07807e --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php @@ -0,0 +1,37 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + /** + * Handle the event. + */ + public function handle(ConfirmRoadAccessNeedEvent $event): void + { + Http::post($this->url, + array( + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + ))->throw(); + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php b/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php new file mode 100644 index 00000000..ce50d817 --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php @@ -0,0 +1,38 @@ +url = config('harim_web_services.reject.url'); + $this->username = config('harim_web_services.reject.username'); + $this->password = config('harim_web_services.reject.password'); + } + + /** + * @throws RequestException + */ + public function handle(RejectRequestEvent $event): void + { + Http::post($this->url, + array( + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + '' => $event->harim->id, + ))->throw(); + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php deleted file mode 100644 index 861f9670..00000000 --- a/app/Listeners/V3/Dashboard/Harim/SendConfirmGuaranteeLetterNeed.php +++ /dev/null @@ -1,36 +0,0 @@ -url = config('harim_web_services.reject.url'); - $this->username = config('harim_web_services.reject.username'); - $this->password = config('harim_web_services.reject.password'); - } - public function handle(ConfirmGuaranteeLetterNeedProcessed $event): void - { - // - } - public function subscribe(Dispatcher $events) - { - $events->listen( - ConfirmGuaranteeLetterNeedProcessed::class, - SendConfirmGuaranteeLetterNeed::class, - ); - } - -} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php deleted file mode 100644 index 437d655c..00000000 --- a/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessEditNeed.php +++ /dev/null @@ -1,39 +0,0 @@ -url = config('harim_web_services.reject.url'); - $this->username = config('harim_web_services.reject.username'); - $this->password = config('harim_web_services.reject.password'); - } - - public function handle(ConfirmRoadAccessEditNeedProcessed $event): void - { - // - } - - public function subscribe(Dispatcher $events) - { - $events->listen( - ConfirmRoadAccessEditNeedProcessed::class, - SendConfirmNoRoadAccessEditNeed::class, - ); - } - -} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php deleted file mode 100644 index 2fe8a514..00000000 --- a/app/Listeners/V3/Dashboard/Harim/SendConfirmNoRoadAccessNeed.php +++ /dev/null @@ -1,39 +0,0 @@ -url = config('harim_web_services.reject.url'); - $this->username = config('harim_web_services.reject.username'); - $this->password = config('harim_web_services.reject.password'); - } - - public function handle(ConfirmNoRoadAccessNeedProcessed $event): void - { - // - } - - public function subscribe(Dispatcher $events) - { - $events->listen( - ConfirmNoRoadAccessNeedProcessed::class, - SendConfirmNoRoadAccessNeed::class, - ); - - } - -} diff --git a/app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php b/app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php deleted file mode 100644 index d5bf4cb3..00000000 --- a/app/Listeners/V3/Dashboard/Harim/SendConfirmRoadAccessNeed.php +++ /dev/null @@ -1,47 +0,0 @@ -url = config('harim_web_services.reject.url'); - $this->username = config('harim_web_services.reject.username'); - $this->password = config('harim_web_services.reject.password'); - - } - - /** - * Handle the event. - */ - public function handle(ConfirmRoadAccessNeedProcessed $event): void - { - Http::post($this->url, - array( - 'username' => $this->username, - 'password' => $this->password, - 'harim_id' => $this->harimId, - 'status' => 'rejected', - 'message' => $this->message, - ))->throw(); - } - public function subscribe(Dispatcher $events) - { - $events->listen( - ConfirmRoadAccessNeedProcessed::class , - SendConfirmRoadAccessNeed::class, - ); - - } -} diff --git a/app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php b/app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php deleted file mode 100644 index 37b6b025..00000000 --- a/app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php +++ /dev/null @@ -1,51 +0,0 @@ -url = config('harim_web_services.reject.url'); - $this->username = config('harim_web_services.reject.username'); - $this->password = config('harim_web_services.reject.password'); - } - - /** - * @throws RequestException - */ - public function handle(RejectRequestProcessed $event): void - { - Http::post($this->url, - array( - 'username' => $this->username, - 'password' => $this->password, - 'harim_id' => $this->harimId, - 'status' => 'need road access', - 'panjareh_vahed_id' => $this->panjareh_vahed_id, - 'date' => now(), - 'single choice' => 'accepted', - - ))->throw(); - } - - public function subscribe(Dispatcher $events) - { - $events->listen( - RejectRequestProcessed::class, - SendRejectNotification::class, 'handle' - ); - - } -} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index e077a519..3686d436 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,6 +2,16 @@ namespace App\Providers; +use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedEvent; +use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedEvent; +use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedEvent; +use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent; +use App\Events\V3\Dashboard\Harim\RejectRequestEvent; +use App\Listeners\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedListener; +use App\Listeners\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedListener; +use App\Listeners\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedListener; +use App\Listeners\V3\Dashboard\Harim\ConfirmRoadAccessNeedListener; +use App\Listeners\V3\Dashboard\Harim\RejectRequestListener; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; @@ -25,6 +35,22 @@ class EventServiceProvider extends ServiceProvider 'Illuminate\Auth\Events\Login' => [ 'App\Listeners\LogSuccessfulLogin', ], + + RejectRequestEvent::class => [ + RejectRequestListener::class + ], + ConfirmRoadAccessNeedEvent::class => [ + ConfirmRoadAccessNeedListener::class + ], + ConfirmNoRoadAccessNeedEvent::class => [ + ConfirmNoRoadAccessNeedListener::class + ], + ConfirmRoadAccessEditNeedEvent::class => [ + ConfirmRoadAccessEditNeedListener::class + ], + ConfirmGuaranteeLetterNeedEvent::class => [ + ConfirmGuaranteeLetterNeedListener::class + ] ]; /**