<?php

namespace App\Http\Services\V1_1;

use App\Generated\V1_1\Messages\Tags\GetAllTagMessage;
use App\Models\TagModel;

class TagsService
{
    public function getAllTag(GetAllTagMessage $message)
    {
        $datas = TagModel::get();
        $result = array();
        foreach ($datas as $data) {
            $tmp = array(
                'id' => (string)$data['id'],
                'name' => $data['name'],
                'group' => (string)$data['group']
            );
            $result[$data['group']][] = $tmp;
        }

        $message->setResponse($result);
    }
}
