openInTaskStream($project, filled($key) ? $key : null); } $project->save(); return $project; } protected function openInTaskStream(Project $project, ?string $key): void { try { app(OpenInTaskStream::class)->handle($project, Auth::user(), app(TokenStore::class)->accessToken(), $key); } catch (ValidationException $e) { // The action names the API's fields; here they live under `data`. throw ValidationException::withMessages( collect($e->errors())->mapWithKeys(fn (array $messages, string $field) => ["data.{$field}" => $messages])->all(), ); } catch (HttpException $e) { Notification::make()->danger()->title($e->getMessage())->send(); throw (new Halt)->rollBackDatabaseTransaction(); } } protected function getCreatedNotification(): ?Notification { $notification = parent::getCreatedNotification(); $key = $this->getRecord()->taskstream_key; if ($notification === null || $key === null) { return $notification; } $url = app(TaskStreamClient::class)->projectUrl($key); return $notification ->body(__('panel.projects.taskstream.created', ['url' => $url])) ->actions([ Action::make('taskstream') ->label(__('panel.projects.taskstream.open')) ->url($url, shouldOpenInNewTab: true), ]) ->persistent(); } }