first commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Website;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TrackingScriptController extends Controller
|
||||
{
|
||||
public function script(string $trackingId): Response
|
||||
{
|
||||
$website = Website::where('tracking_id', $trackingId)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if (! $website) {
|
||||
return response('', 404)
|
||||
->header('Content-Type', 'application/javascript');
|
||||
}
|
||||
|
||||
$collectUrl = route('collect.store');
|
||||
|
||||
$js = view('tracking.tracker', [
|
||||
'trackingId' => $trackingId,
|
||||
'collectUrl' => $collectUrl,
|
||||
])->render();
|
||||
|
||||
return response($js)
|
||||
->header('Content-Type', 'application/javascript')
|
||||
->header('Cache-Control', 'public, max-age=3600');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user