<?php

namespace App\Classes\Modules\Transactions\ControllersLogic;

use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\ListsBillGroups;
use App\Http\Resources\BillGroupResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListBillGroupsLogic extends AbstractControllerLogic
{
    /**
     * ListTransactionsLogic constructor.
     * @param ListsBillGroups $listsBillGroups
     */
    public function __construct(ListsBillGroups $listsBillGroups)
    {
        $this->listsBillGroups = $listsBillGroups;
    }

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Retrieved Bill Groups',
            'message' => 'You have successfully retrieved a list of bill groups'
        ];
    }

    /** @var ListsBillGroups */
    private $listsBillGroups;

    public function logic(Request $request) : JsonResponse
    {
        $query = $this->listsBillGroups->execute($this->listsBillGroups->deserializeFilters($request->input('filters')));

        return $this->collectionResponse(BillGroupResource::collection($query));
    }

}
