validate([ 'episode_id' => 'required', 'captcha' => 'required|captcha' ]); $episode = Episode::where('id', $request->input('episode_id'))->firstOrFail(); // Increase download count, as we assume the user // downloads after submitting the captcha $download = Downloads::find($episode->getDownloadByType('FHD')->id); $oldCount = $download->count; $download->count++; $download->save(); return response()->json([ 'message' => 'success', 'download_url' => $download->url, 'download_count' => $oldCount, ], 200); } }