dev-think-one /
laravel-notification-tracker
| 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 ClickController 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
Loading history...
|
|||
| 20 | 1 | $tracker->incrementClick()->save(); |
|
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | 2 | return Response::redirectTo($request->input(NotificationTracker::clickTrackerUrlParameterName(), '/')); |
|
| 25 | } |
||
| 26 | } |
||
| 27 |