Files
Discount-Bandit/app/Http/Controllers/GetLinkUsingUrlController.php
Cybrarist 9841b2d9f3 add other related links in the user account api
add chart history api lik
enhance product record ui in link
add notification if user selected a currency without api exchange key
2025-11-24 09:34:15 +04:00

36 lines
865 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Link;
use App\Services\URLParserService;
use Illuminate\Http\Request;
class GetLinkUsingUrlController extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(Request $request, URLParserService $service)
{
$validated = $request->validate([
'url' => ['required', 'url', 'string'],
]);
$service->setup($validated['url']);
$link = Link::with(['store', 'store.currency'])
->firstWhere([
'store_id' => $service->store?->id,
'key' => $service->product_key,
]);
if (! $link)
return response()->json(['message' => 'Link not found'], 404);
$link->url = route('filament.admin.resources.links.edit', $link);
return $link;
}
}