Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
stremehard committed Jan 15, 2025
1 parent 5a978b4 commit e16163d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Log;

class WebhookController extends Controller
{
Expand All @@ -26,11 +27,15 @@ public function __construct()
*/
public function subscribe(Request $request): Response
{
Log::ingo('Webhook received', $request->all());

collect($request->get('events'))->each(function ($event) use ($request) {
if (! data_get($event, 'data.resource')) {
throw new \Exception('No resource provided by webhook');
}

Log::info('Webhook event received', $event);

return match (data_get($event, 'action')) {
'product.updated' => event(new ProductUpdated($event)),
'product.created' => event(new ProductCreated($event)),
Expand Down

0 comments on commit e16163d

Please sign in to comment.