write event for harim
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\V3\Dashboard\Harim;
|
||||
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ConfirmGuaranteeLetterNeedProcessed
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(public Harim $harim){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\V3\Dashboard\Harim;
|
||||
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ConfirmNoRoadAccessNeedProcessed
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(public Harim $harim){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(public Harim $harim){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(public Harim $harim){}
|
||||
}
|
||||
35
app/Events/V3/Dashboard/Harim/RejectRequestProcessed.php
Normal file
35
app/Events/V3/Dashboard/Harim/RejectRequestProcessed.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\V3\Dashboard\Harim;
|
||||
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RejectRequestProcessed
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $harimId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public Harim $harim,)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('channel-name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedProcessed;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class SendConfirmGuaranteeLetterNeed
|
||||
{
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
protected int $harimId;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\ConfirmNoRoadAccessEditNeedProcessed;
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedProcessed;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class SendConfirmNoRoadAccessEditNeed
|
||||
{
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
protected int $harimId;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedProcessed;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class SendConfirmNoRoadAccessNeed
|
||||
{
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
protected int $harimId;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedProcessed;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SendConfirmRoadAccessNeed
|
||||
{
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
protected int $harimId;
|
||||
protected string $message = 'این درخواست نیاز به راه دسترسی دارد';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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,
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
51
app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php
Normal file
51
app/Listeners/V3/Dashboard/Harim/SendRejectNotification.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\RejectRequestProcessed;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SendRejectNotification
|
||||
{
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
protected int $harimId;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user