<?php


namespace App\Classes\Modules\Transactions\ControllersLogic;

use App\Models\Company;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\GeneratesCompanyBalanceAccount;

class FetchCompanyAccountBalanceLogic extends AbstractControllerLogic
{
    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Retrieved Company Balance Account',
            'message' => 'You have successfully retrieved company balance account'
        ];
    }

    /** @var GeneratesCompanyBalanceAccount */
    private $generatesCompanyBalanceAccount;

    /**
     * FetchCompanyAccountBalanceLogic constructor.
     * @param GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount
     */
    public function __construct(GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount)
    {
        $this->generatesCompanyBalanceAccount = $generatesCompanyBalanceAccount;
    }

    public function logic(Request $request) : JsonResponse
    {
        $company = Company::find($request->route('id'));

        return $this->response(['data' => $this->generatesCompanyBalanceAccount->execute($company)]);

    }



}
