public function redirect($url) { try { $link = URL::where('alt', $url)->first(); $link->increment('view_count'); return redirect($link->url); } catch (\Exception $e) { return json_encode(['error' => 'URL not found.', 'message' => $e->getMessage()]); } }
public function view($url) { $counter = URL::where('count_alt', $url)->first(); return view('count', compact('counter')); }