Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

realodix/urlhub

532 stars
1 code files
View realodix/urlhub on GitHub

app/Http/Controllers/UrlRedirectController.php

Open in GitHub
use App\Models\Url;
use App\Services\UrlRedirectionService;
use Illuminate\Support\Facades\DB;
 
class UrlRedirectController extends Controller
{
public function __invoke(UrlRedirectionService $service, string $key)
{
return DB::transaction(function () use ($service, $key) {
$url = Url::whereKeyword($key)->firstOrFail();
 
return $service->handleHttpRedirect($url);
});
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.