This commit is contained in:
Bozhidar 2024-05-15 11:15:51 +03:00
parent 19fd0e35d8
commit 22034da019
3 changed files with 21 additions and 14 deletions

View file

@ -2,8 +2,8 @@
namespace App\Console\Commands;
use App\Jobs\ApacheBuild;
use App\Models\Domain;
use App\VirtualHosts\ApacheBuild;
use Illuminate\Console\Command;
class RunDomainRepair extends Command
@ -27,8 +27,6 @@ class RunDomainRepair extends Command
*/
public function handle()
{
$apache = new ApacheBuild();
$apache->fixPermissions();
$apache->build();
ApacheBuild::dispatch(true);
}
}

View file

@ -1,21 +1,33 @@
<?php
namespace App\VirtualHosts;
namespace App\Jobs;
use App\MasterDomain;
use App\Models\Domain;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ApacheBuild
class ApacheBuild implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $fixPermissions = false;
public function fixPermissions()
/**
* Create a new job instance.
*/
public function __construct($fixPermissions = false)
{
$this->fixPermissions = true;
$this->fixPermissions = $fixPermissions;
}
public function build()
/**
* Execute the job.
*/
public function handle(): void
{
$getAllDomains = Domain::all();
$virtualHosts = [];
@ -65,7 +77,5 @@ class ApacheBuild
file_put_contents('/etc/apache2/apache2.conf', $apache2);
shell_exec('systemctl reload apache2');
}
}

View file

@ -5,8 +5,8 @@ namespace App\Models;
use App\Actions\ApacheWebsiteDelete;
use App\Events\DomainIsCreated;
use App\Events\ModelDomainDeleting;
use App\Jobs\ApacheBuild;
use App\ShellApi;
use App\VirtualHosts\ApacheBuild;
use App\VirtualHosts\DTO\ApacheVirtualHostSettings;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
@ -87,8 +87,7 @@ class Domain extends Model
$model->configureVirtualHost(true);
$apacheBuild = new ApacheBuild();
$apacheBuild->build();
ApacheBuild::dispatch();
});