<?php


namespace App\Classes\Modules\Transactions\ControllersLogic;

use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\ListsTransactions;
use App\Http\Resources\BookingResource;
use App\Http\Resources\TransactionResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

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

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

    /** @var ListsTransactions */
    private $listsTransactions;



    public function logic(Request $request) : JsonResponse
    {

        $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));

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

    }



}
