This commit is contained in:
Bozhidar Slaveykov 2024-04-06 11:49:06 +03:00
parent 6904a51da7
commit 02b8a43f75
9 changed files with 31 additions and 32 deletions

View file

@ -72,8 +72,12 @@ class ApacheWebsiteCreate
$domainPublic = $domainRoot . '/public_html';
$homeRoot = '/home/' . $this->user;
}
dd([
'allDomainsRoot' => $allDomainsRoot,
'domainRoot' => $domainRoot,
'domainPublic' => $domainPublic,
'homeRoot' => $homeRoot
]);
$apacheVirtualHostConfigs = app()->virtualHostManager->getConfigs($this->additionalServices);

View file

@ -10,7 +10,7 @@ use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ModelWebsiteCreated
class ModelDomainCreated
{
use Dispatchable, InteractsWithSockets, SerializesModels;

View file

@ -10,7 +10,7 @@ use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ModelWebsiteDeleting
class ModelDomainDeleting
{
use Dispatchable, InteractsWithSockets, SerializesModels;

View file

@ -3,8 +3,9 @@
namespace App\Listeners;
use App\Actions\ApacheWebsiteCreate;
use App\Events\ModelWebsiteCreated;
use App\Events\ModelDomainCreated;
use App\Models\Customer;
use App\Models\Domain;
use App\Models\HostingPackage;
use App\Models\HostingPlan;
use App\Models\HostingSubscription;
@ -29,7 +30,7 @@ class ModelDomainCreatedListener
*/
public function handle(ModelDomainCreated $event): void
{
$findDomain = \App\Models\Domain::where('id', $event->model->id)->first();
$findDomain = Domain::where('id', $event->model->id)->first();
if (!$findDomain) {
return;
}
@ -49,7 +50,7 @@ class ModelDomainCreatedListener
$newApacheWebsite->setAdditionalServices($findHostingPlan->additional_services);
$newApacheWebsite->setFeatures($findHostingPlan->features);
$create = $newApacheWebsite->handle();
$create = $newApacheWebsite->handle();
dd($create);

View file

@ -3,7 +3,7 @@
namespace App\Listeners;
use App\Actions\ApacheWebsiteDelete;
use App\Events\ModelWebsiteDeleting;
use App\Events\ModelDomainDeleting;
use App\ShellApi;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
@ -21,7 +21,7 @@ class ModelDomainDeletingListener
/**
* Handle the event.
*/
public function handle(ModelWebsiteDeleting $event): void
public function handle(ModelDomainDeleting $event): void
{
$domainRoot = '/home/'.$event->model->domain_username.'/domains/'.$event->model->domain;

View file

@ -35,14 +35,7 @@ class ModelHostingSubscriptionCreatedListener
return;
}
if (strlen($findCustomer->name) > 5) {
$systemUsername = $this->_generateUsername($findCustomer->name);
} elseif (strlen($findCustomer->email) > 5) {
$systemUsername = $this->_generateUsername($findCustomer->email);
} else {
$systemUsername = $this->_generateUsername(Str::random(10));
}
$systemUsername = $this->_generateUsername($event->model->domain);
$systemUsername = $systemUsername . $findCustomer->id . $findHostingSubscription->id;
$getLinuxUser = new GetLinuxUser();

View file

@ -2,7 +2,8 @@
namespace App\Models;
use App\Actions\ApacheWebsiteCreate;
use App\Events\ModelDomainCreated;
use App\Events\ModelDomainDeleting;
use App\ShellApi;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@ -20,13 +21,13 @@ class Domain extends Model
{
parent::boot();
// static::created(function ($model) {
// event(new \App\Events\ModelWebsiteCreated($model));
// });
//
// static::deleting(function ($model) {
// event(new \App\Events\ModelWebsiteDeleting($model));
// });
static::created(function ($model) {
event(new ModelDomainCreated($model));
});
static::deleting(function ($model) {
event(new ModelDomainDeleting($model));
});
}

View file

@ -9,8 +9,8 @@ use App\Events\ModelHostingSubscriptionDeleting;
use App\Listeners\ModelHostingSubscriptionCreatedListener;
use App\Listeners\ModelHostingSubscriptionDeletingListener;
use App\Events\ModelWebsiteCreated;
use App\Events\ModelWebsiteDeleting;
use App\Events\ModelDomainCreated;
use App\Events\ModelDomainDeleting;
use App\Listeners\ModelDomainCreatedListener;
use App\Listeners\ModelDomainDeletingListener;
@ -49,8 +49,8 @@ class AppServiceProvider extends ServiceProvider
Gate::define('delete-customer', [CustomerPolicy::class, 'delete']);
Event::listen(ModelWebsiteCreated::class,ModelDomainCreatedListener::class);
Event::listen(ModelWebsiteDeleting::class,ModelDomainDeletingListener::class);
Event::listen(ModelDomainCreated::class,ModelDomainCreatedListener::class);
Event::listen(ModelDomainDeleting::class,ModelDomainDeletingListener::class);
Event::listen(ModelHostingSubscriptionCreated::class,ModelHostingSubscriptionCreatedListener::class);
Event::listen(ModelHostingSubscriptionDeleting::class,ModelHostingSubscriptionDeletingListener::class);

View file

@ -1,8 +1,8 @@
PHYRE_PHP=/usr/local/phyre/php/bin/php
#rm -rf composer.lock
#$PHYRE_PHP composer.phar i
#$PHYRE_PHP composer.phar dump-autoload
rm -rf composer.lock
$PHYRE_PHP composer.phar i
$PHYRE_PHP composer.phar dump-autoload
$PHYRE_PHP artisan migrate