Last active
November 9, 2022 22:15
-
-
Save Casmo/20ae06f5f4fd8b921e738734b5347f24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 VaporDevelopmentEvent implements ShouldBroadcast | |
{ | |
use Dispatchable, InteractsWithSockets, SerializesModels; | |
public $message; | |
public function __construct($message) | |
{ | |
$this->message = $message; | |
} | |
public function broadcastOn() | |
{ | |
return new Channel('aws.channel'); | |
} | |
public function broadcastAs() | |
{ | |
return 'aws.event'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Route; | |
use App\Domain\Utility\Events\VaporDevelopmentEvent; | |
use Illuminate\Support\Facades\Artisan; | |
Route::any('/webhooks/aws/events', function () { | |
if (config('app.env') !== 'staging' || !env('PUSHER_APP_ID')) { | |
abort(404); | |
return; | |
} | |
$payload = base64_encode(json_encode(request()->all())); | |
event(new VaporDevelopmentEvent($payload)); | |
return 'ok'; | |
}); | |
Route::any('/webhooks/aws/payload', function () { | |
if (config('app.env') !== 'local' || !env('PUSHER_APP_ID')) { | |
abort(404); | |
return; | |
} | |
$payload = request()->get('payload'); | |
Artisan::call('vapor:handle '. $payload); | |
return 'ok'; | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment