'Created Remark', 'message' => 'You have successfully created a new Remark' ]; } /** @var CanCreateRemark */ private $canCreateRemark; /** @var FetchesDistrict */ private $fetchesDistrict; /** @var FetchesCompany */ private $fetchesCompany; /** @var CreatesRemark */ private $createsRemark; /** * CreateRemarkLogic constructor. * @param CanCreateRemark $canCreateRemark * @param FetchesDistrict $fetchesDistrict * @param FetchesCompany $fetchesCompany * @param CreatesRemark $createsRemark */ public function __construct(CanCreateRemark $canCreateRemark, FetchesDistrict $fetchesDistrict, FetchesCompany $fetchesCompany, CreatesRemark $createsRemark) { $this->canCreateRemark = $canCreateRemark; $this->fetchesDistrict = $fetchesDistrict; $this->fetchesCompany = $fetchesCompany; $this->createsRemark = $createsRemark; } /** * @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 { $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); $object = new RemarkObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); $this->canCreateRemark->passes($object); $query = $this->createsRemark->execute($this->fetchesCompany->execute(['id' => $request->input('company_id')]), $object); return $this->resourceResponse(new RemarkResource($query)); } }