diff --git a/src/Fieldtypes/Tag.php b/src/Fieldtypes/Tag.php new file mode 100644 index 0000000..2967ef6 --- /dev/null +++ b/src/Fieldtypes/Tag.php @@ -0,0 +1,46 @@ +get('https://uptime.com/api/v1/check-tags/'); + + return collect(Arr::get($response->json(), 'results')) + ->map(fn (array $tagData) => ['id' => $tagData['tag'], 'title' => $tagData['tag']]) + ->sortBy('title'); + } + + // public function preProcessIndex($id) + // { + // if (is_null($id)) { + // return; + // } + + // return [[ + // 'id' => $id, + // 'title' => $id, + // ]]; + // } + + protected function toItemArray($id) + { + if (! $id) { + return []; + } + + return [ + 'id' => $id, + 'title' => $id, + ]; + } +}