This commit is contained in:
Bozhidar Slaveykov 2024-04-01 19:57:14 +03:00
parent 6a4c37fd77
commit 1850b6953e
2 changed files with 29 additions and 2 deletions

View file

@ -10,6 +10,7 @@ class ApacheWebsiteCreate
public $domain; public $domain;
public $user; public $user;
public $email; public $email;
public $password;
public function setDomain($domain) public function setDomain($domain)
{ {
@ -25,6 +26,12 @@ class ApacheWebsiteCreate
{ {
$this->email = $email; $this->email = $email;
} }
public function setPassword($password)
{
$this->password = $password;
}
public function handle() public function handle()
{ {
@ -36,7 +43,7 @@ class ApacheWebsiteCreate
$createLinuxWebUser = new CreateLinuxWebUser(); $createLinuxWebUser = new CreateLinuxWebUser();
$createLinuxWebUser->setUsername($this->user); $createLinuxWebUser->setUsername($this->user);
$createLinuxWebUser->setEmail($this->email); $createLinuxWebUser->setEmail($this->email);
$createLinuxWebUser->setPassword('password123'); $createLinuxWebUser->setPassword($this->password);
$createLinuxWebUserOutput = $createLinuxWebUser->handle(); $createLinuxWebUserOutput = $createLinuxWebUser->handle();
$linuxUser = $getLinuxUser->handle(); $linuxUser = $getLinuxUser->handle();
} }
@ -63,5 +70,13 @@ class ApacheWebsiteCreate
$fileManagerApi->filePutContents($settings['domainRoot'].'/index.php', "PHP Time: <?php echo time(); ?> Domain: " . $settings['domain']); $fileManagerApi->filePutContents($settings['domainRoot'].'/index.php', "PHP Time: <?php echo time(); ?> Domain: " . $settings['domain']);
return [
'domain' => $this->domain,
'user' => $this->user,
'email' => $this->email,
'linuxUser' => $linuxUser,
'apache2Sample' => $apache2Sample
];
} }
} }

View file

@ -2,6 +2,7 @@
namespace App\Listeners; namespace App\Listeners;
use App\Actions\ApacheWebsiteCreate;
use App\Events\ModelWebsiteCreating; use App\Events\ModelWebsiteCreating;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
@ -21,8 +22,19 @@ class ModelWebsiteCreatingListener
*/ */
public function handle(ModelWebsiteCreating $event): void public function handle(ModelWebsiteCreating $event): void
{ {
$model = $event->model;
dd($event); $username = md5($model->domain);
$email = $username . '@phyrepanel.test';
$password = uniqid();
$newApacheWebsite = new ApacheWebsiteCreate();
$newApacheWebsite->setDomain($model->domain);
$newApacheWebsite->setUser($username);
$newApacheWebsite->setEmail($email);
$newApacheWebsite->setPassword($password);
$create = $newApacheWebsite->handle();
} }
} }