input('rowId'); if (! is_string($rowId) || ! UuidHelper::isValid($rowId)) { return false; } $product = $this->executor->execute( $this->getProductWithPricingQuery, new GetProductQueryInput($this->getProductId()), ); return $product !== null && Gate::allows('addToBasket', $product); } public function toAddToBasketInput(): AddToBasketInput { return new AddToBasketInput( $this->getProductId(), $this->integer('qty') ); } public function getProductId(): ProductId { return new ProductId( UuidHelper::fromString( $this->string('rowId')->value() ) ); } /** @return array */ public function rules(): array { return [ 'rowId' => ['required', 'string', 'uuid', 'exists:products,id'], 'qty' => ['required', 'integer', 'min:1'], ]; } }