PHP code example of antiques / laravel-sendgrid-events
1. Go to this page and download the library: Download antiques/laravel-sendgrid-events library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
antiques / laravel-sendgrid-events example snippets
// Include the class
use \LaravelSendgridEvents\Models\SendgridEvent;
/**
* ...
*/
// Get all records:
SendgridEvent::all();
// Get all by message ID:
$sendgridMessageId = 'abc123';
SendgridEvent::where('sg_message_id', $sendgridMessageId)->all();
// Get all by event ID:
$sendgridEventId = 'xyz987';
SendgridEvent::where('sg_event_id', $sendgridEventId)->all();
// Get all by event type
SendgridEvent::where('event', LaravelSendgridEvents\Enums::PROCESSED)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::DEFERRED)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::DELIVERED)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::OPEN)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::CLICK)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::BOUNCE)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::DROPPED)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::SPAMREPORT)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::UNSUBSCRIBE)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::GROUP_UNSUBSCRIBE)->all();
SendgridEvent::where('event', LaravelSendgridEvents\Enums::GROUP_RESUBSCRIBE)->all();
// Count all bounces
SendgridEvent::where('event', LaravelSendgridEvents\Enums::BOUNCE)->count();
// Get a record
$event = SendgridEvent::first();
// Included with all event types
$event->timestamp;
$event->email;
$event->event;
$event->categories;
$event->sg_event_id;
$event->sg_message_id;
$event->payload; // Array of full payload sent by Sendgrid
// Get a record
$event = SendgridEvent::first();
// Access the reason attribute,
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.