Example of Collection Methods: Push in Kovah/LinkAce

File app/Repositories/LinkRepository.php (link to Github)
class LinkRepository
{
    //
    protected static function processTaxonomy(string $model, array $entries): Collection
    {
        $newEntries = collect();

        foreach ($entries as $entry) {
            if (is_int($entry)) {
                $newEntry = Tag::find($entry);
            } else {
                $newEntry = $model::firstOrCreate([
                    'user_id' => auth()->id(),
                    'name' => trim($entry),
                ]);
            }

            if ($newEntry !== null) {
                $newEntries->push($newEntry->id);
            }
        }

        return $newEntries;
    }
}