This commit is contained in:
Bozhidar 2024-10-17 11:09:45 +03:00
parent aff951e9d6
commit 1441eaa6e4
4 changed files with 70 additions and 4 deletions

View file

@ -0,0 +1,36 @@
<?php
namespace App\Events;
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 DomainIsChanged
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*/
public function __construct()
{
//
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}

View file

@ -2,6 +2,7 @@
namespace app\Http\Controllers\Api;
use App\Events\DomainIsChanged;
use App\Http\Controllers\ApiController;
use App\Jobs\ApacheBuild;
use App\Models\Domain;
@ -111,6 +112,8 @@ class DomainsController extends ApiController
ApacheBuild::dispatchSync();
event(new DomainIsChanged($findDomain));
return response()->json([
'status' => 'ok',
'message' => 'Domain updated',

View file

@ -0,0 +1,26 @@
<?php
namespace App\Listeners;
use App\Events\DomainIsChanged;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class DomainIsChangedListener
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*/
public function handle(DomainIsChanged $event): void
{
//
}
}

View file

@ -2,12 +2,14 @@
namespace App\Providers;
use App\Events\DomainIsChanged;
use App\Events\ModelDomainCreated;
use App\Events\ModelDomainDeleting;
use App\Events\ModelHostingSubscriptionCreated;
use app\Events\ModelHostingSubscriptionCreating;
use App\Events\ModelHostingSubscriptionDeleting;
use App\Events\ModelPhyreServerCreated;
use App\Listeners\DomainIsChangedListener;
use App\Listeners\ModelDomainCreatedListener;
use App\Listeners\ModelDomainDeletingListener;
use App\Listeners\ModelHostingSubscriptionCreatingListener;
@ -30,13 +32,12 @@ class EventServiceProvider extends ServiceProvider
Registered::class => [
SendEmailVerificationNotification::class,
],
ModelDomainDeleting::class => [
ModelDomainDeletingListener::class,
],
ModelPhyreServerCreated::class => [
ModelPhyreServerCreatedListener::class,
],
DomainIsChanged::class => [
DomainIsChangedListener::class,
],
];
/**