$url, 'name' => $name, 'content' => $content, ]); foreach ((array) $categories as $category) { $tag = Tag::firstOrCreate(['tag' => $category]); $bookmark->tags()->save($tag); } $mpSyndicateTo = null; if (Arr::get($request, 'mp-syndicate-to')) { $mpSyndicateTo = Arr::get($request, 'mp-syndicate-to'); } if (Arr::get($request, 'properties.mp-syndicate-to')) { $mpSyndicateTo = Arr::get($request, 'properties.mp-syndicate-to'); } $mpSyndicateTo = Arr::wrap($mpSyndicateTo); foreach ($mpSyndicateTo as $uid) { $target = SyndicationTarget::where('uid', $uid)->first(); if ($target && $target->service_name === 'Twitter') { SyndicateBookmarkToTwitter::dispatch($bookmark); break; } } ProcessBookmark::dispatch($bookmark); return $bookmark; } /** * Given a URL, attempt to save it to the Internet Archive. * * @throws InternetArchiveException */ public function getArchiveLink(string $url): string { $client = resolve(Client::class); try { $response = $client->request('GET', 'https://web.archive.org/save/' . $url); } catch (ClientException $e) { //throw an exception to be caught throw new InternetArchiveException(); } if ($response->hasHeader('Content-Location')) { if (Str::startsWith(Arr::get($response->getHeader('Content-Location'), 0), '/web')) { return $response->getHeader('Content-Location')[0]; } } //throw an exception to be caught throw new InternetArchiveException(); } }