spatie / laravel-tags

Add tags and taggable behaviour to your Laravel app

Home Page:https://freek.dev/609-an-opinionated-tagging-package-for-laravel-apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is is possible to pluck a translated name as key?

horaceho opened this issue · comments

Tag::where('type', 'Groups')->pluck('name', 'name');

What I get:

Illuminate\Support\Collection {
     all: [
       "{"en": "A", "zh": ""}" => "A",
       "{"en": "B", "zh": "乙"}" => "B",
     ],
   }

What I want:

Illuminate\Support\Collection {
     all: [
       "A" => "A",
       "B" => "B",
     ],
   }

Thanks for the great package!

My bad. Should be:

Tag::where('type', 'Groups')->get()->pluck('name', 'name');