2023-03-20 13:04:22 +01:00
|
|
|
<?php
|
|
|
|
|
2023-03-21 10:56:49 +01:00
|
|
|
namespace App\Actions\RemoteProcess;
|
2023-03-20 13:04:22 +01:00
|
|
|
|
2023-03-21 11:02:16 +01:00
|
|
|
use App\Data\RemoteProcessArgs;
|
2023-03-20 13:04:22 +01:00
|
|
|
use App\Jobs\ExecuteCoolifyProcess;
|
2023-03-21 11:32:38 +01:00
|
|
|
use Spatie\Activitylog\Models\Activity;
|
2023-03-20 13:04:22 +01:00
|
|
|
|
2023-03-21 10:56:49 +01:00
|
|
|
class DispatchRemoteProcess
|
2023-03-20 13:04:22 +01:00
|
|
|
{
|
|
|
|
protected Activity $activity;
|
|
|
|
|
2023-03-21 11:32:38 +01:00
|
|
|
public function __construct(RemoteProcessArgs $remoteProcessArgs){
|
2023-03-20 13:04:22 +01:00
|
|
|
$this->activity = activity()
|
2023-03-21 11:32:38 +01:00
|
|
|
->withProperties($remoteProcessArgs->toArray())
|
2023-03-21 10:08:36 +01:00
|
|
|
->log("Awaiting command to start...\n\n");
|
2023-03-20 13:04:22 +01:00
|
|
|
}
|
|
|
|
|
2023-03-21 10:08:36 +01:00
|
|
|
public function __invoke(): Activity
|
2023-03-20 13:04:22 +01:00
|
|
|
{
|
|
|
|
$job = new ExecuteCoolifyProcess($this->activity);
|
|
|
|
|
|
|
|
dispatch($job);
|
|
|
|
|
2023-03-21 10:31:16 +01:00
|
|
|
$this->activity->refresh();
|
|
|
|
|
2023-03-20 13:04:22 +01:00
|
|
|
return $this->activity;
|
|
|
|
}
|
|
|
|
}
|