<?php

namespace App\Classes\Modules\Companies\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Http\Resources\GeneralTypeResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListBusinessTypesLogic extends AbstractControllerLogic
{

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


    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\AccessForbiddenException
     * @throws \App\Classes\Exceptions\MalformedRequestException
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    public function logic(Request $request) : JsonResponse
    {
        $businessTypes = [];

        foreach(BusinessType::BUSINESS_TYPE_LIST as $key => $val) {
            $type = (object)["id" => $key, "type" => $val];
            array_push($businessTypes, $type);
        }

        return $this->collectionResponse(GeneralTypeResource::collection($businessTypes));
    }
}