https://dev.to/visuellverstehen https://dev.to/juliawarnke Usually when building a custom relationship fieldtype you want to work with data from somewhere else than statamic. In this example we extended the relationship fieldtype in order to provide a list of imported tags.
public function getIndexItems($request) { return collect($this->tags) ->filter(function ($tag) use ($request) { if (! $request->search) { return true; } return Str::contains($tag['title'], $request->search); }); }}
This could be done like this: public function getIndexItems($request) { $tags = collect($this->tags)->filter(function ($tag) use ($request) { if (! $request->search) { return true; } return Str::contains($tag['title'], $request->search); }); return $this->paginate($tags); } protected function paginate($tags): LengthAwarePaginator { $currentPage = Paginator::resolveCurrentPage(); $perPage = 50; $total = $tags->count(); $result = $total ?