'Detach Company Connection From Connection Segment', 'message' => 'You have successfully detached Company Connection from Connection segment' ]; } /** @var FetchesCompany */ private $fetchesCompany; /** @var FetchesCompanyConnection */ private $fetchesCompanyConnection; /** @var FetchesSegment */ private $fetchesSegment; /** @var RemovesCompanyConnectionFromConnectionSegment */ private $removesCompanyConnectionFromConnectionSegment; /** * RemoveCompanyFromSegmentLogic constructor. * @param FetchesCompany $fetchesCompany * @param FetchesCompanyConnection $fetchesCompanyConnection * @param FetchesSegment $fetchesSegment * @param RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment */ public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, FetchesSegment $fetchesSegment, RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment) { $this->fetchesCompany = $fetchesCompany; $this->fetchesCompanyConnection = $fetchesCompanyConnection; $this->fetchesSegment = $fetchesSegment; $this->removesCompanyConnectionFromConnectionSegment = $removesCompanyConnectionFromConnectionSegment; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\MalformedRequestException */ public function logic(Request $request) : JsonResponse { $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); $companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]); $segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]); $this->removesCompanyConnectionFromConnectionSegment->execute($companyConnection, $segment); return $this->resourceResponse(new CompanyResource($company)); } }