$url, 'name' => $name, 'content' => $content, ]); foreach ((array) $categories as $category) { $tag = Tag::firstOrCreate(['tag' => $category]); $bookmark->tags()->save($tag); } ProcessBookmark::dispatch($bookmark); return $bookmark; } /** * Given a URL, attempt to save it to the Internet Archive. * * @throws InternetArchiveException */ public function getArchiveLink(string $url): string { $response = Http::get('https://web.archive.org/save/'.$url); if ($response->clientError()) { // throw an exception to be caught throw new InternetArchiveException; } $contentLocation = $response->header('Content-Location'); if ($contentLocation !== '' && Str::startsWith($contentLocation, '/web')) { return $contentLocation; } // throw an exception to be caught throw new InternetArchiveException; } }