Created
October 2, 2017 19:38
-
-
Save woganmay/fc8825d1cb131f6f861bf09b657d3901 to your computer and use it in GitHub Desktop.
Manage a tracking pixel
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\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