1 | <?php |
||
2 | |||
3 | namespace NotificationTracker\Http\Controllers; |
||
4 | |||
5 | use Illuminate\Http\Request; |
||
6 | use Illuminate\Routing\Controller; |
||
7 | use Illuminate\Support\Facades\Response; |
||
8 | use NotificationTracker\Models\TrackedChannel; |
||
9 | use NotificationTracker\NotificationTracker; |
||
10 | |||
11 | class PixelController extends Controller |
||
12 | { |
||
13 | 2 | public function __invoke(Request $request) |
|
14 | { |
||
15 | 2 | if ($uuid = $request->route('uuid', '')) { |
|
16 | // TODO: move to queue job to speed up updating? |
||
17 | /** @var TrackedChannel $tracker */ |
||
18 | 2 | $tracker = NotificationTracker::modelClass('channel')::query()->uuid($uuid)->first(); |
|
19 | 2 | if ($tracker) { |
|
0 ignored issues
–
show
introduced
by
![]() |
|||
20 | 1 | $tracker->incrementOpen()->save(); |
|
21 | } |
||
22 | } |
||
23 | |||
24 | 2 | return Response::file(NotificationTracker::pixelFilePath(), [ |
|
25 | 2 | 'Cache-Control' => 'private, no-cache, no-cache=Set-Cookie, no-store, must-revalidate', |
|
26 | 2 | 'Pragma' => 'no-cache', |
|
27 | 2 | ]); |
|
28 | } |
||
29 | } |
||
30 |