where('id', $this->input('rowId')) ->first(); 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( Uuid::fromString( $this->string('rowId')->value() ) ); } /** @return array */ public function rules(): array { return [ 'rowId' => ['required', 'string', 'uuid', 'exists:products,id'], 'qty' => ['required', 'integer', 'min:1'], ]; } }