src/Http/Controllers/PostsController.php
private function collectTags($incomingTags)
    {
        $allTags = WinkTag::all();

        return collect($incomingTags)->map(function ($incomingTag) use ($allTags) {
            $tag = $allTags->where('slug', Str::slug($incomingTag['name']))->first();

            if (! $tag) {
                $tag = WinkTag::create([
                    'id' => $id = Str::uuid(),
                    'name' => $incomingTag['name'],
                    'slug' => Str::slug($incomingTag['name']),
                ]);
            }

            return (string) $tag->id;
        })->toArray();
    }
private function collectTags($incomingTags)
    {
        $allTags = WinkTag::all();

        return collect($incomingTags)->map(function ($incomingTag) use ($allTags) {
            $tag = $allTags->where('slug', Str::slug($incomingTag['name']))->first();

            if (! $tag) {
                $tag = WinkTag::create([
                    'id' => $id = Str::uuid(),
                    'name' => $incomingTag['name'],
                    'slug' => Str::slug($incomingTag['name']),
                ]);
            }

            return (string) $tag->id;
        })->toArray();
    }
private function collectTags ( $ incomingTags ) { $ allTags = WinkTag :: all ( ) ; return collect ( $ incomingTags ) -> map ( function ( $ incomingTag ) use ( $ allTags ) { $ tag = $ allTags -> where ( 'slug' , Str :: slug ( $ incomingTag [ 'name' ] ) ) -> first ( ) ; if ( ! $ tag ) { $ tag = WinkTag :: create ( [ 'id' => $ id = Str :: uuid ( ) , 'name' => $ incomingTag [ 'name' ] , 'slug' => Str :: slug ( $ incomingTag [ 'name' ] ) , ] ) ; } return ( string ) $ tag -> id ; } ) -> toArray ( ) ; }
Tags incoming from the request.

@param  array  $incomingTags
@return array
Tags incoming from the request .