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