service = App::make(UserService::class); } function updated() { if (strlen($this->query) > 2) { $this->display = ""; $this->queryResults = $this->service->search($this->query); } } public function add($id) { if (!str_contains($this->value, $id)) { $this->value .= $id . "|"; $this->selection[] = $this->service->getById($id); } } public function remove($id) { if (str_contains($this->value, $id)) { $this->value = str_replace($id . "|", "", $this->value); $this->selection = collect($this->selection)->reject(function ($item) use ($id) { return $item->id == $id; }); } } public function render() { return view('livewire.assign-to', [ "queryResults" => $this->queryResults, "simpleResult" => $this->simpleResult, "selection" => $this->selection ]); } }