22 lines
381 B
PHP
22 lines
381 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Ad;
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
class AdController extends Controller
|
|
{
|
|
public function redirect(Ad $ad): RedirectResponse
|
|
{
|
|
$ad->increment('click_count');
|
|
|
|
$url = $ad->getTargetUrl();
|
|
if (!$url) {
|
|
abort(404);
|
|
}
|
|
|
|
return redirect()->away($url);
|
|
}
|
|
}
|