route()->parameter('bundle')), 404); $bundle = $request->route()->parameters()['bundle']; abort_if(! is_a($bundle, Bundle::class), 404); // Aborting if Auth token is not provided abort_if(empty($request->auth), 403); // Aborting if auth_token is different from URL param abort_if($bundle->preview_token !== $request->auth, 403); // Aborting if bundle expired abort_if($bundle->expires_at->isBefore(Carbon::now()), 404); // Aborting if max download is reached abort_if( ($bundle->max_downloads ?? 0) > 0 && $bundle->downloads >= $bundle->max_downloads, 404); // Else resuming return $next($request); } }