'Assign Company To Segment', 'message' => 'You have successfully assigned Company to segment' ]; } /** @var FetchesCompany */ private $fetchesCompany; /** @var AssignSegmentProcessor */ private $assignCompanyToSegmentProcessor; /** * AssignCompanyToSegmentLogic constructor. * @param FetchesCompany $fetchesCompany * @param AssignSegmentProcessor $assignCompanyToSegmentProcessor */ public function __construct(FetchesCompany $fetchesCompany, AssignSegmentProcessor $assignCompanyToSegmentProcessor) { $this->fetchesCompany = $fetchesCompany; $this->assignCompanyToSegmentProcessor = $assignCompanyToSegmentProcessor; } /** * @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 { $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); $this->assignCompanyToSegmentProcessor->execute($company, $request->input('segment_id')); return $this->resourceResponse(new CompanyResource($company)); } }