Skip to content

Instantly share code, notes, and snippets.

@woganmay
Created October 2, 2017 19:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save woganmay/fc8825d1cb131f6f861bf09b657d3901 to your computer and use it in GitHub Desktop.
Manage a tracking pixel
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Jobs\SendOpened;
class PixelController extends Controller
{
public function pixel($send, Request $request)
{
// Process the tracking pixel
// Queue the job to flag the hit
dispatch(new SendOpened($send, time()));
// And respond with the pixel
if (!file_exists(storage_path('pixel.png')))
{
file_put_contents(storage_path('pixel.png'), base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="));
}
return response()
->download(storage_path('pixel.png'), '1x1.png', ['Content-Type' => 'image/png'], $disposition = 'inline');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment