opnform-host-nginx/api/app/Models/Forms/Form.php

330 lines
8.3 KiB
PHP
Raw Normal View History

2022-09-20 21:59:52 +02:00
<?php
namespace App\Models\Forms;
use App\Events\Models\FormCreated;
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
use App\Models\Integration\FormIntegration;
2022-09-20 21:59:52 +02:00
use App\Models\Integration\FormZapierWebhook;
use App\Models\Traits\CachableAttributes;
use App\Models\Traits\CachesAttributes;
2022-09-20 21:59:52 +02:00
use App\Models\User;
use App\Models\Workspace;
use Database\Factories\FormFactory;
2024-02-23 11:54:12 +01:00
use Illuminate\Database\Eloquent\Casts\Attribute;
2022-09-20 21:59:52 +02:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
2024-02-23 11:54:12 +01:00
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
2022-09-20 21:59:52 +02:00
use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
use Stevebauman\Purify\Facades\Purify;
use Carbon\Carbon;
2022-09-20 21:59:52 +02:00
class Form extends Model implements CachableAttributes
2022-09-20 21:59:52 +02:00
{
use CachesAttributes;
2024-02-23 11:54:12 +01:00
use HasFactory;
use HasSlug;
use SoftDeletes;
public const DARK_MODE_VALUES = ['auto', 'light', 'dark'];
public const SIZES = ['sm', 'md', 'lg'];
public const BORDER_RADIUS = ['none', 'small', 'full'];
2024-02-23 11:54:12 +01:00
public const THEMES = ['default', 'simple', 'notion'];
2022-09-20 21:59:52 +02:00
2024-02-23 11:54:12 +01:00
public const WIDTHS = ['centered', 'full'];
public const VISIBILITY = ['public', 'draft', 'closed'];
2022-09-20 21:59:52 +02:00
public const LANGUAGES = ['en', 'fr', 'hi', 'es', 'ar', 'zh', 'ja', 'bn', 'pt', 'ru', 'ur', 'pa', 'de', 'jv', 'ko', 'vi', 'te', 'mr', 'ta', 'tr', 'sk', 'cs', 'eu', 'gl', 'ca', 'sv', 'pl'];
2022-09-20 21:59:52 +02:00
protected $fillable = [
'workspace_id',
'creator_id',
'properties',
'removed_properties',
'title',
'tags',
'visibility',
2022-09-20 21:59:52 +02:00
// Customization
'language',
'font_family',
'custom_domain',
'size',
'border_radius',
2022-09-20 21:59:52 +02:00
'theme',
'width',
'layout_rtl',
2022-09-20 21:59:52 +02:00
'cover_picture',
'logo_picture',
'dark_mode',
'color',
'uppercase_labels',
'no_branding',
'transparent_background',
// Custom Code
'custom_code',
// Submission
'submit_button_text',
'database_fields_update',
're_fillable',
're_fill_button_text',
'submitted_text',
'redirect_url',
'use_captcha',
Add reCAPTCHA support and update captcha provider handling (#647) * Add reCAPTCHA support and update captcha provider handling - Introduced reCAPTCHA as an additional captcha provider alongside hCaptcha. - Updated form request validation to handle different captcha providers based on user selection. - Added a new validation rule for reCAPTCHA. - Modified the forms model to include a 'captcha_provider' field. - Created a migration to add the 'captcha_provider' column to the forms table. - Updated frontend components to support dynamic rendering of captcha based on the selected provider. - Enhanced tests to cover scenarios for both hCaptcha and reCAPTCHA. These changes improve the flexibility of captcha options available to users, enhancing form security and user experience. * fix pint * change comment text * Refactor captcha implementation and integrate new captcha components - Removed the old RecaptchaV2 component and replaced it with a new implementation that supports both reCAPTCHA and hCaptcha through a unified CaptchaInput component. - Updated the OpenForm component to utilize the new CaptchaInput for dynamic captcha rendering based on user-selected provider. - Cleaned up the package.json by removing the deprecated @hcaptcha/vue3-hcaptcha dependency. - Enhanced form initialization to set a default captcha provider. - Improved error handling and cleanup for both reCAPTCHA and hCaptcha scripts. These changes streamline captcha integration, improve maintainability, and enhance user experience by providing a more flexible captcha solution. * Refactor captcha error messages and localization support * Refactor registration process to integrate reCAPTCHA - Replaced hCaptcha implementation with reCAPTCHA in RegisterController and related test cases. - Updated validation rules to utilize g-recaptcha-response instead of h-captcha-response. - Modified RegisterForm component to support reCAPTCHA, including changes to the form data structure and component references. - Enhanced test cases to reflect the new reCAPTCHA integration, ensuring proper validation and response handling. These changes improve security and user experience during the registration process by adopting a more widely used captcha solution. * Fix reCAPTCHA configuration and update RegisterForm styling - Corrected the configuration key for reCAPTCHA in RegisterController from 'services.recaptcha.secret_key' to 'services.re_captcha.secret_key'. - Updated the styling of the Captcha input section in RegisterForm.vue to improve layout consistency. These changes ensure proper reCAPTCHA functionality and enhance the user interface during the registration process. * Fix reCAPTCHA configuration in RegisterTest to use the correct key format - Updated the configuration key for reCAPTCHA in RegisterTest from 'services.recaptcha.secret_key' to 'services.re_captcha.secret_key' to ensure proper functionality during tests. This change aligns the test setup with the recent updates in the reCAPTCHA integration, improving the accuracy of the registration process tests. --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-12-18 16:35:09 +01:00
'captcha_provider',
2022-09-20 21:59:52 +02:00
'closes_at',
'closed_text',
'max_submissions_count',
'max_submissions_reached_text',
'editable_submissions',
'editable_submissions_button_text',
2023-04-12 13:17:05 +02:00
'confetti_on_submission',
'show_progress_bar',
'auto_save',
'auto_focus',
Partial submissions (#705) * Implement partial form submissions feature * Add status filtering for form submissions * Add Partial Submission in Analytics * improve partial submission * fix lint * Add type checking for submission ID in form submission job * on form stats Partial Submissions only if enable * Partial Submissions is PRO Feature * Partial Submissions is PRO Feature * improvement migration * Update form submission status labels to 'Submitted' and 'In Progress' * start partial sync when dataFormValue update * badge size xs * Refactor partial submission hash management * Refactor partial form submission handling in PublicFormController * fix submissiona * Refactor form submission ID handling and metadata processing - Improve submission ID extraction and decoding across controllers - Add robust handling for submission hash and ID conversion - Enhance metadata processing in StoreFormSubmissionJob - Simplify submission storage logic with clearer metadata extraction - Minor UI improvements in FormSubmissions and OpenTable components * Enhance form submission settings UI with advanced partial submission options - Restructure partial submissions toggle with more descriptive label - Add advanced submission options section with Pro tag - Improve help text for partial submissions feature - Update ProTag with more detailed upgrade modal description * Refactor partial form submission sync mechanism - Improve partial submission synchronization in usePartialSubmission composable - Replace interval-based sync with Vue's reactive watch - Add robust handling for different form data input patterns - Implement onBeforeUnmount hook for final sync attempt - Enhance data synchronization reliability and performance * Improve partial form submission validation and synchronization * fix lint * Refactor submission identifier processing in PublicFormController - Updated the docblock for the method responsible for processing submission identifiers to clarify its functionality. The method now explicitly states that it converts a submission hash or string ID into a numeric submission_id, ensuring consistent internal storage format. These changes aim to improve code documentation and enhance understanding of the method's purpose and behavior. * Enhance Form Logic Condition Checker to Exclude Partial Submissions - Updated the query in FormLogicConditionChecker to exclude submissions with a status of 'partial', ensuring that only complete submissions are processed. - Minor formatting adjustment in the docblock of PublicFormController for improved clarity. These changes aim to refine submission handling and enhance the accuracy of form logic evaluations. * Partial Submission Test * Refactor FormSubmissionController and PartialSubmissionTest for Consistency - Updated the `FormSubmissionController` to improve code consistency by adjusting the formatting of anonymous functions in the `filter` and `first` methods. - Modified `PartialSubmissionTest` to simplify the `Storage::fake()` method call, removing the unnecessary 'local' parameter for better clarity. These changes aim to enhance code readability and maintainability across the form submission handling and testing components. * Enhance FormSubmissionController and EditSubmissionTest for Clarity - Added validation to the `FormSubmissionController` by introducing `$submissionData = $request->validated();` to ensure that only validated data is processed for form submissions. - Improved code readability in the `FormSubmissionController` by adjusting the formatting of anonymous functions in the `filter` and `first` methods. - Removed unnecessary blank lines in the `EditSubmissionTest` to streamline the test setup. These changes aim to enhance data integrity during form submissions and improve overall code clarity and maintainability. --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2025-04-28 17:33:55 +02:00
'enable_partial_submissions',
2022-09-20 21:59:52 +02:00
// Security & Privacy
'can_be_indexed',
'password',
// Custom SEO
2024-02-23 11:54:12 +01:00
'seo_meta',
2022-09-20 21:59:52 +02:00
];
protected function casts(): array
{
return [
'properties' => 'array',
'database_fields_update' => 'array',
'closes_at' => 'datetime',
'tags' => 'array',
'removed_properties' => 'array',
Stripe Payment (#679) * oAuth for Stripe * Stripe Payment Frontend - WIP * Payment block backend validation and new package for stripe * change stripe scopes * update PaymentBlockConfigurationRule * Set loader on provider modal * stripe oauth * PaymentFieldOptions as seprate component * validate Stripe account * Payment intent * Stripe Payment as composable * confirmCardPayment working * Set payment errors on form.errors * Validate card other fields * Store payment id to database and on submission add link for view payment on stripe * FormPaymentController no need auth middleware * paymentinput error display on field * Make payment block as input change 'nf-payment' to 'payment' * Refactor payment processing and error handling * Multi lang & direction support on payment * reset card on change direction or local * use connected account for loadstripe * validate OAuthProvider before delete it * payment improvements * display payment by stripe * use stripe_currencies.json * Form Payment testcase * Enhance form auto-save behavior for payment forms * Restrict payment block in self-hosted environments * validate form before process payment * Refactor Nuxt Configuration for Improved Development Server Settings - Removed the existing Vite server configuration for hot module replacement (HMR) as it was no longer necessary. - Introduced a new `devServer` configuration to specify the host and port for the development server, allowing for more flexible environment setup based on environment variables. These changes aim to streamline the development process by enhancing server configuration and ensuring better adaptability to different environments. * Enhance Payment Handling and User Experience in Forms - Refactored `FormPaymentController` to improve handling of Stripe account retrieval, including better error messages for both editor preview and public forms. - Updated `OAuthProviderController` to utilize caching for OAuth connection context, enhancing performance and user experience during account connections. - Improved `PaymentInput.client.vue` to display a loading state and a preview message for users, guiding them to save the form for payment activation. - Modified various components to standardize payment-related messages and improve localization support across multiple languages. - Removed the deprecated `connections.vue` page to streamline the codebase. These changes aim to enhance the overall user experience when handling payments and improve the maintainability of the payment-related components. * Refactor Payment Handling and Enhance User Experience in Forms - Updated `FormPaymentController` to utilize a new method for checking if the Stripe provider belongs to any workspace user, improving security and error logging. - Modified `OAuthProviderController` to streamline the OAuth provider creation process by directly using the service object. - Enhanced `Workspace` model with a new method to verify provider ownership, improving code clarity and maintainability. - Improved `PaymentInput.client.vue` to handle loading states and error messages more effectively, enhancing user feedback during payment processing. - Refactored `useFormInput.js` to include an `isAdminPreview` prop for better context handling in form components. These changes aim to improve the overall user experience when handling payments and enhance the maintainability of the payment-related components. * Enhance Payment Validation and User Experience in Forms - Updated `UserFormRequest` to improve workspace handling during form submissions, allowing for better context in validation rules. - Modified `PaymentBlockConfigurationRule` to include workspace validation, ensuring that payment providers are associated with the correct workspace, enhancing security and error logging. - Improved `PaymentInput.client.vue` to dynamically determine the success state of payment processing, providing clearer user feedback. - Updated various localization files to include a payment disclaimer, ensuring users are informed about credit card charges during payment processing. These changes aim to enhance the overall user experience when handling payments and improve the maintainability of payment-related components. * Enhance Payment Features and User Experience in Forms - Added checks in `FormPaymentController` to disable payment features for self-hosted instances, improving clarity for users regarding feature availability. - Updated `PaymentBlockConfigurationRule` to change the minimum amount validation from 0.5 to 1, ensuring stricter payment requirements. - Enhanced `PaymentInput.client.vue` with dark mode support for various UI elements, improving accessibility and user experience in different themes. - Modified `useFormInput.js` to include an `isDark` prop, allowing for better theme handling in form components. - Updated error messages in `useStripeElements.js` to include periods for consistency and improved user feedback. These changes aim to enhance the overall user experience when handling payments and improve the maintainability of payment-related components. * Enhance Payment Input Component with Focus Handling and Theme Support - Updated `PaymentInput.client.vue` to include focus and blur event handlers, improving user interaction by visually indicating when the card input is focused. - Enhanced theme support by adding new properties in `form-themes.js` for `PaymentInput`, allowing for better styling and transitions based on focus state. - Introduced a new `isCardFocused` reactive reference to manage the focus state of the card input, enhancing the overall user experience. These changes aim to improve the usability and visual feedback of the payment input component, aligning with recent enhancements to user experience in payment forms. * Refactor Payment Handling and Improve Code Consistency - Updated various files to enhance code consistency by adding spaces in arrow function definitions, improving readability and adhering to coding standards. - Modified `PaymentBlockConfigurationRule.php`, `FormPaymentController.php`, and `Workspace.php` to ensure uniformity in the use of arrow functions. - Enhanced `PaymentInput.client.vue` and other components by improving the formatting of template elements for better visual structure. - Updated `useStripeElements.js` to streamline state management and improve clarity in the handling of Stripe elements. These changes aim to improve code maintainability and readability across the payment handling components, ensuring a more consistent coding style throughout the codebase. * Enhance Form Model and Logging Configuration - Added a new 'auto_save' boolean property to the Form model, allowing for automatic saving of form data. - Updated the logging configuration to include a 'combined' channel that stacks multiple log channels, improving logging flexibility and error tracking. - Modified the FormFactory to set a default value for 'auto_save' to false, ensuring consistent behavior across form instances. - Improved error message structure in FormPaymentTest to provide clearer feedback when a payment block is missing. These changes aim to enhance the functionality of forms and improve logging capabilities, contributing to better maintainability and user experience. * Update api/config/logging.php Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Refactor Payment Error Handling and Localization Updates - Updated `FormPaymentTest.php` to improve code consistency by adding spaces in arrow function definitions, enhancing readability. - Modified `useStripeElements.js` to replace hardcoded error messages with localized strings, improving user experience and maintainability. - Enhanced various localization files (e.g., `en.json`, `fr.json`, `de.json`, etc.) to include new error messages related to payment processing, ensuring users receive clear and consistent feedback across different languages. These changes aim to enhance the clarity of error handling in payment processes and improve the overall user experience through better localization support. * Enhance AddFormBlock and FieldOptions with Authentication Checks - Added an icon to indicate authentication requirements for blocks in `AddFormBlock.vue`, improving user awareness of access restrictions. - Implemented alert notifications using `useAlert()` for unauthorized block additions and input cloning, enhancing user feedback. - Updated `FieldOptions.vue` to conditionally render payment field options, ensuring relevant options are displayed based on the field type. - Modified `blocks_types.json` to include an `auth_required` property for specific block types, facilitating authentication checks. These changes aim to improve user experience by providing clear indications of authentication requirements and enhancing form functionality. * Enhance Authentication Checks in AddFormBlock Component - Updated `AddFormBlock.vue` to conditionally render authentication-required icons based on user authentication status, improving user awareness of access restrictions. - Implemented additional authentication checks in the `addBlock` and `handleInputClone` functions, utilizing `useAlert()` for notifying users when login is required to add blocks or clone inputs. - Introduced a computed property to manage the authenticated state, streamlining the authentication logic within the component. These changes aim to enhance user experience by providing clear indications of authentication requirements and improving the functionality of the form component. * Enhance PaymentInput Component with Disabled State Support - Updated `PaymentInput.client.vue` to include a `disabled` prop for the card holder name and email inputs, improving form accessibility and user experience by preventing interaction when necessary. - Modified the card options to respect the `disabled` state, ensuring consistent behavior across the payment input fields. These changes aim to enhance the usability of the payment input component by providing better control over user interactions. * Add Payment Condition Logic and Update Filters - Introduced a new payment condition in `FormLogicConditionChecker.php` to handle 'paid' and 'not_paid' states, enhancing form logic capabilities. - Added corresponding payment comparators in `open_filters.json` for both API and client, ensuring consistent validation and expected types for payment conditions. - Updated the JavaScript logic in `FormLogicConditionChecker.js` to include the new payment condition checks, improving the overall functionality of form conditions. These changes aim to enhance the form logic related to payment states, providing better validation and user experience in payment-related forms. * Refactor Authentication Checks in AddFormBlock and Working Form Store - Removed redundant authentication checks from `AddFormBlock.vue` for adding blocks and cloning inputs, streamlining the logic. - Centralized authentication validation in `working_form.js` to ensure consistent user feedback when authentication is required for specific block types. - Enhanced user experience by utilizing `useAlert()` for notifying users about login requirements, improving clarity and interaction. These changes aim to simplify the authentication logic and improve user notifications regarding access restrictions in form components. * Refactor Feature Flags and Update Payment Input Logic - Updated `FeatureFlagsController.php` to utilize the `Cache` facade directly, improving code clarity and consistency. - Modified `PaymentInput.client.vue` to enhance the display logic for payment previews, ensuring a better user experience by conditionally showing messages based on the state of the Stripe account. - Removed the `STRIPE_PUBLISHABLE_KEY` from `runtimeConfig.js` to streamline the configuration and replaced it with a computed property that retrieves the key from feature flags, improving maintainability. - Adjusted the `.env.example` file to maintain consistency in environment variable definitions. These changes aim to enhance the clarity of feature flag management and improve the user experience in payment interactions by refining the logic and configuration handling. * Update Stripe Configuration in Services - Modified the `services.php` configuration file to enhance the Stripe integration by providing default values for `client_secret` and `redirect` URI. This change ensures that the application can fallback to a predefined secret and a specific callback URL, improving the robustness of the payment service setup. These changes aim to streamline the configuration process for Stripe, ensuring that necessary values are always available for the application to function correctly. --------- Co-authored-by: Chirag Chhatrala <chirag.chhatrala@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-04-10 12:04:25 +02:00
'seo_meta' => 'object',
Partial submissions (#705) * Implement partial form submissions feature * Add status filtering for form submissions * Add Partial Submission in Analytics * improve partial submission * fix lint * Add type checking for submission ID in form submission job * on form stats Partial Submissions only if enable * Partial Submissions is PRO Feature * Partial Submissions is PRO Feature * improvement migration * Update form submission status labels to 'Submitted' and 'In Progress' * start partial sync when dataFormValue update * badge size xs * Refactor partial submission hash management * Refactor partial form submission handling in PublicFormController * fix submissiona * Refactor form submission ID handling and metadata processing - Improve submission ID extraction and decoding across controllers - Add robust handling for submission hash and ID conversion - Enhance metadata processing in StoreFormSubmissionJob - Simplify submission storage logic with clearer metadata extraction - Minor UI improvements in FormSubmissions and OpenTable components * Enhance form submission settings UI with advanced partial submission options - Restructure partial submissions toggle with more descriptive label - Add advanced submission options section with Pro tag - Improve help text for partial submissions feature - Update ProTag with more detailed upgrade modal description * Refactor partial form submission sync mechanism - Improve partial submission synchronization in usePartialSubmission composable - Replace interval-based sync with Vue's reactive watch - Add robust handling for different form data input patterns - Implement onBeforeUnmount hook for final sync attempt - Enhance data synchronization reliability and performance * Improve partial form submission validation and synchronization * fix lint * Refactor submission identifier processing in PublicFormController - Updated the docblock for the method responsible for processing submission identifiers to clarify its functionality. The method now explicitly states that it converts a submission hash or string ID into a numeric submission_id, ensuring consistent internal storage format. These changes aim to improve code documentation and enhance understanding of the method's purpose and behavior. * Enhance Form Logic Condition Checker to Exclude Partial Submissions - Updated the query in FormLogicConditionChecker to exclude submissions with a status of 'partial', ensuring that only complete submissions are processed. - Minor formatting adjustment in the docblock of PublicFormController for improved clarity. These changes aim to refine submission handling and enhance the accuracy of form logic evaluations. * Partial Submission Test * Refactor FormSubmissionController and PartialSubmissionTest for Consistency - Updated the `FormSubmissionController` to improve code consistency by adjusting the formatting of anonymous functions in the `filter` and `first` methods. - Modified `PartialSubmissionTest` to simplify the `Storage::fake()` method call, removing the unnecessary 'local' parameter for better clarity. These changes aim to enhance code readability and maintainability across the form submission handling and testing components. * Enhance FormSubmissionController and EditSubmissionTest for Clarity - Added validation to the `FormSubmissionController` by introducing `$submissionData = $request->validated();` to ensure that only validated data is processed for form submissions. - Improved code readability in the `FormSubmissionController` by adjusting the formatting of anonymous functions in the `filter` and `first` methods. - Removed unnecessary blank lines in the `EditSubmissionTest` to streamline the test setup. These changes aim to enhance data integrity during form submissions and improve overall code clarity and maintainability. --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2025-04-28 17:33:55 +02:00
'enable_partial_submissions' => 'boolean',
Stripe Payment (#679) * oAuth for Stripe * Stripe Payment Frontend - WIP * Payment block backend validation and new package for stripe * change stripe scopes * update PaymentBlockConfigurationRule * Set loader on provider modal * stripe oauth * PaymentFieldOptions as seprate component * validate Stripe account * Payment intent * Stripe Payment as composable * confirmCardPayment working * Set payment errors on form.errors * Validate card other fields * Store payment id to database and on submission add link for view payment on stripe * FormPaymentController no need auth middleware * paymentinput error display on field * Make payment block as input change 'nf-payment' to 'payment' * Refactor payment processing and error handling * Multi lang & direction support on payment * reset card on change direction or local * use connected account for loadstripe * validate OAuthProvider before delete it * payment improvements * display payment by stripe * use stripe_currencies.json * Form Payment testcase * Enhance form auto-save behavior for payment forms * Restrict payment block in self-hosted environments * validate form before process payment * Refactor Nuxt Configuration for Improved Development Server Settings - Removed the existing Vite server configuration for hot module replacement (HMR) as it was no longer necessary. - Introduced a new `devServer` configuration to specify the host and port for the development server, allowing for more flexible environment setup based on environment variables. These changes aim to streamline the development process by enhancing server configuration and ensuring better adaptability to different environments. * Enhance Payment Handling and User Experience in Forms - Refactored `FormPaymentController` to improve handling of Stripe account retrieval, including better error messages for both editor preview and public forms. - Updated `OAuthProviderController` to utilize caching for OAuth connection context, enhancing performance and user experience during account connections. - Improved `PaymentInput.client.vue` to display a loading state and a preview message for users, guiding them to save the form for payment activation. - Modified various components to standardize payment-related messages and improve localization support across multiple languages. - Removed the deprecated `connections.vue` page to streamline the codebase. These changes aim to enhance the overall user experience when handling payments and improve the maintainability of the payment-related components. * Refactor Payment Handling and Enhance User Experience in Forms - Updated `FormPaymentController` to utilize a new method for checking if the Stripe provider belongs to any workspace user, improving security and error logging. - Modified `OAuthProviderController` to streamline the OAuth provider creation process by directly using the service object. - Enhanced `Workspace` model with a new method to verify provider ownership, improving code clarity and maintainability. - Improved `PaymentInput.client.vue` to handle loading states and error messages more effectively, enhancing user feedback during payment processing. - Refactored `useFormInput.js` to include an `isAdminPreview` prop for better context handling in form components. These changes aim to improve the overall user experience when handling payments and enhance the maintainability of the payment-related components. * Enhance Payment Validation and User Experience in Forms - Updated `UserFormRequest` to improve workspace handling during form submissions, allowing for better context in validation rules. - Modified `PaymentBlockConfigurationRule` to include workspace validation, ensuring that payment providers are associated with the correct workspace, enhancing security and error logging. - Improved `PaymentInput.client.vue` to dynamically determine the success state of payment processing, providing clearer user feedback. - Updated various localization files to include a payment disclaimer, ensuring users are informed about credit card charges during payment processing. These changes aim to enhance the overall user experience when handling payments and improve the maintainability of payment-related components. * Enhance Payment Features and User Experience in Forms - Added checks in `FormPaymentController` to disable payment features for self-hosted instances, improving clarity for users regarding feature availability. - Updated `PaymentBlockConfigurationRule` to change the minimum amount validation from 0.5 to 1, ensuring stricter payment requirements. - Enhanced `PaymentInput.client.vue` with dark mode support for various UI elements, improving accessibility and user experience in different themes. - Modified `useFormInput.js` to include an `isDark` prop, allowing for better theme handling in form components. - Updated error messages in `useStripeElements.js` to include periods for consistency and improved user feedback. These changes aim to enhance the overall user experience when handling payments and improve the maintainability of payment-related components. * Enhance Payment Input Component with Focus Handling and Theme Support - Updated `PaymentInput.client.vue` to include focus and blur event handlers, improving user interaction by visually indicating when the card input is focused. - Enhanced theme support by adding new properties in `form-themes.js` for `PaymentInput`, allowing for better styling and transitions based on focus state. - Introduced a new `isCardFocused` reactive reference to manage the focus state of the card input, enhancing the overall user experience. These changes aim to improve the usability and visual feedback of the payment input component, aligning with recent enhancements to user experience in payment forms. * Refactor Payment Handling and Improve Code Consistency - Updated various files to enhance code consistency by adding spaces in arrow function definitions, improving readability and adhering to coding standards. - Modified `PaymentBlockConfigurationRule.php`, `FormPaymentController.php`, and `Workspace.php` to ensure uniformity in the use of arrow functions. - Enhanced `PaymentInput.client.vue` and other components by improving the formatting of template elements for better visual structure. - Updated `useStripeElements.js` to streamline state management and improve clarity in the handling of Stripe elements. These changes aim to improve code maintainability and readability across the payment handling components, ensuring a more consistent coding style throughout the codebase. * Enhance Form Model and Logging Configuration - Added a new 'auto_save' boolean property to the Form model, allowing for automatic saving of form data. - Updated the logging configuration to include a 'combined' channel that stacks multiple log channels, improving logging flexibility and error tracking. - Modified the FormFactory to set a default value for 'auto_save' to false, ensuring consistent behavior across form instances. - Improved error message structure in FormPaymentTest to provide clearer feedback when a payment block is missing. These changes aim to enhance the functionality of forms and improve logging capabilities, contributing to better maintainability and user experience. * Update api/config/logging.php Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Refactor Payment Error Handling and Localization Updates - Updated `FormPaymentTest.php` to improve code consistency by adding spaces in arrow function definitions, enhancing readability. - Modified `useStripeElements.js` to replace hardcoded error messages with localized strings, improving user experience and maintainability. - Enhanced various localization files (e.g., `en.json`, `fr.json`, `de.json`, etc.) to include new error messages related to payment processing, ensuring users receive clear and consistent feedback across different languages. These changes aim to enhance the clarity of error handling in payment processes and improve the overall user experience through better localization support. * Enhance AddFormBlock and FieldOptions with Authentication Checks - Added an icon to indicate authentication requirements for blocks in `AddFormBlock.vue`, improving user awareness of access restrictions. - Implemented alert notifications using `useAlert()` for unauthorized block additions and input cloning, enhancing user feedback. - Updated `FieldOptions.vue` to conditionally render payment field options, ensuring relevant options are displayed based on the field type. - Modified `blocks_types.json` to include an `auth_required` property for specific block types, facilitating authentication checks. These changes aim to improve user experience by providing clear indications of authentication requirements and enhancing form functionality. * Enhance Authentication Checks in AddFormBlock Component - Updated `AddFormBlock.vue` to conditionally render authentication-required icons based on user authentication status, improving user awareness of access restrictions. - Implemented additional authentication checks in the `addBlock` and `handleInputClone` functions, utilizing `useAlert()` for notifying users when login is required to add blocks or clone inputs. - Introduced a computed property to manage the authenticated state, streamlining the authentication logic within the component. These changes aim to enhance user experience by providing clear indications of authentication requirements and improving the functionality of the form component. * Enhance PaymentInput Component with Disabled State Support - Updated `PaymentInput.client.vue` to include a `disabled` prop for the card holder name and email inputs, improving form accessibility and user experience by preventing interaction when necessary. - Modified the card options to respect the `disabled` state, ensuring consistent behavior across the payment input fields. These changes aim to enhance the usability of the payment input component by providing better control over user interactions. * Add Payment Condition Logic and Update Filters - Introduced a new payment condition in `FormLogicConditionChecker.php` to handle 'paid' and 'not_paid' states, enhancing form logic capabilities. - Added corresponding payment comparators in `open_filters.json` for both API and client, ensuring consistent validation and expected types for payment conditions. - Updated the JavaScript logic in `FormLogicConditionChecker.js` to include the new payment condition checks, improving the overall functionality of form conditions. These changes aim to enhance the form logic related to payment states, providing better validation and user experience in payment-related forms. * Refactor Authentication Checks in AddFormBlock and Working Form Store - Removed redundant authentication checks from `AddFormBlock.vue` for adding blocks and cloning inputs, streamlining the logic. - Centralized authentication validation in `working_form.js` to ensure consistent user feedback when authentication is required for specific block types. - Enhanced user experience by utilizing `useAlert()` for notifying users about login requirements, improving clarity and interaction. These changes aim to simplify the authentication logic and improve user notifications regarding access restrictions in form components. * Refactor Feature Flags and Update Payment Input Logic - Updated `FeatureFlagsController.php` to utilize the `Cache` facade directly, improving code clarity and consistency. - Modified `PaymentInput.client.vue` to enhance the display logic for payment previews, ensuring a better user experience by conditionally showing messages based on the state of the Stripe account. - Removed the `STRIPE_PUBLISHABLE_KEY` from `runtimeConfig.js` to streamline the configuration and replaced it with a computed property that retrieves the key from feature flags, improving maintainability. - Adjusted the `.env.example` file to maintain consistency in environment variable definitions. These changes aim to enhance the clarity of feature flag management and improve the user experience in payment interactions by refining the logic and configuration handling. * Update Stripe Configuration in Services - Modified the `services.php` configuration file to enhance the Stripe integration by providing default values for `client_secret` and `redirect` URI. This change ensures that the application can fallback to a predefined secret and a specific callback URL, improving the robustness of the payment service setup. These changes aim to streamline the configuration process for Stripe, ensuring that necessary values are always available for the application to function correctly. --------- Co-authored-by: Chirag Chhatrala <chirag.chhatrala@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-04-10 12:04:25 +02:00
'auto_save' => 'boolean',
];
}
2022-09-20 21:59:52 +02:00
protected $appends = [
'share_url',
];
protected $hidden = [
'workspace_id',
'redirect_url',
'database_fields_update',
'password',
'tags',
2024-02-23 11:54:12 +01:00
'removed_properties',
2022-09-20 21:59:52 +02:00
];
protected $cachableAttributes = [
'is_pro',
'views_count',
2024-02-23 11:54:12 +01:00
'max_file_size',
];
2022-09-20 21:59:52 +02:00
/**
* The event map for the model.
*
* @var array
*/
protected $dispatchesEvents = [
'created' => FormCreated::class,
];
public function getIsProAttribute()
{
2023-12-04 10:43:24 +01:00
return $this->remember('is_pro', 15 * 60, function (): ?bool {
return $this->workspace?->is_pro === true;
});
2022-09-20 21:59:52 +02:00
}
public function getShareUrlAttribute()
{
if ($this->custom_domain) {
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
return 'https://' . $this->custom_domain . '/forms/' . $this->slug;
}
2024-02-23 11:54:12 +01:00
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
return front_url('/forms/' . $this->slug);
2022-09-20 21:59:52 +02:00
}
public function getSubmissionsUrlAttribute()
{
if ($this->custom_domain) {
return 'https://' . $this->custom_domain . '/forms/' . $this->slug . '/show/submissions';
}
return front_url('/forms/' . $this->slug . '/show/submissions');
}
public function getEditUrlAttribute()
{
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
return front_url('/forms/' . $this->slug . '/show');
}
2022-09-20 21:59:52 +02:00
public function getSubmissionsCountAttribute()
{
Partial submissions (#705) * Implement partial form submissions feature * Add status filtering for form submissions * Add Partial Submission in Analytics * improve partial submission * fix lint * Add type checking for submission ID in form submission job * on form stats Partial Submissions only if enable * Partial Submissions is PRO Feature * Partial Submissions is PRO Feature * improvement migration * Update form submission status labels to 'Submitted' and 'In Progress' * start partial sync when dataFormValue update * badge size xs * Refactor partial submission hash management * Refactor partial form submission handling in PublicFormController * fix submissiona * Refactor form submission ID handling and metadata processing - Improve submission ID extraction and decoding across controllers - Add robust handling for submission hash and ID conversion - Enhance metadata processing in StoreFormSubmissionJob - Simplify submission storage logic with clearer metadata extraction - Minor UI improvements in FormSubmissions and OpenTable components * Enhance form submission settings UI with advanced partial submission options - Restructure partial submissions toggle with more descriptive label - Add advanced submission options section with Pro tag - Improve help text for partial submissions feature - Update ProTag with more detailed upgrade modal description * Refactor partial form submission sync mechanism - Improve partial submission synchronization in usePartialSubmission composable - Replace interval-based sync with Vue's reactive watch - Add robust handling for different form data input patterns - Implement onBeforeUnmount hook for final sync attempt - Enhance data synchronization reliability and performance * Improve partial form submission validation and synchronization * fix lint * Refactor submission identifier processing in PublicFormController - Updated the docblock for the method responsible for processing submission identifiers to clarify its functionality. The method now explicitly states that it converts a submission hash or string ID into a numeric submission_id, ensuring consistent internal storage format. These changes aim to improve code documentation and enhance understanding of the method's purpose and behavior. * Enhance Form Logic Condition Checker to Exclude Partial Submissions - Updated the query in FormLogicConditionChecker to exclude submissions with a status of 'partial', ensuring that only complete submissions are processed. - Minor formatting adjustment in the docblock of PublicFormController for improved clarity. These changes aim to refine submission handling and enhance the accuracy of form logic evaluations. * Partial Submission Test * Refactor FormSubmissionController and PartialSubmissionTest for Consistency - Updated the `FormSubmissionController` to improve code consistency by adjusting the formatting of anonymous functions in the `filter` and `first` methods. - Modified `PartialSubmissionTest` to simplify the `Storage::fake()` method call, removing the unnecessary 'local' parameter for better clarity. These changes aim to enhance code readability and maintainability across the form submission handling and testing components. * Enhance FormSubmissionController and EditSubmissionTest for Clarity - Added validation to the `FormSubmissionController` by introducing `$submissionData = $request->validated();` to ensure that only validated data is processed for form submissions. - Improved code readability in the `FormSubmissionController` by adjusting the formatting of anonymous functions in the `filter` and `first` methods. - Removed unnecessary blank lines in the `EditSubmissionTest` to streamline the test setup. These changes aim to enhance data integrity during form submissions and improve overall code clarity and maintainability. --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2025-04-28 17:33:55 +02:00
return $this->submissions()->where('status', FormSubmission::STATUS_COMPLETED)->count();
2022-09-20 21:59:52 +02:00
}
public function getViewsCountAttribute()
{
return $this->remember('views_count', 15 * 60, function (): int {
if (config('database.default') === 'mysql') {
2024-02-23 11:54:12 +01:00
return (int) ($this->views()->count() +
$this->statistics()->sum(DB::raw("json_extract(data, '$.views')")));
}
2024-02-23 11:54:12 +01:00
return $this->views()->count() +
$this->statistics()->sum(DB::raw("cast(data->>'views' as integer)"));
});
2022-09-20 21:59:52 +02:00
}
public function setSubmittedTextAttribute($value)
{
// Strip out unwanted html
$this->attributes['submitted_text'] = Purify::clean($value);
}
2022-10-27 23:31:05 +02:00
public function setTagsAttribute($value)
{
2022-11-01 14:43:14 +01:00
if ($value == '') {
$value = null;
2022-10-27 23:31:05 +02:00
}
$this->attributes['tags'] = json_encode($value);
}
public function setClosesAtAttribute($value)
{
$this->attributes['closes_at'] = ($value) ? Carbon::parse($value)->setTimezone('UTC') : null;
}
public function getClosesAtAttribute($value)
{
if (!$value) {
return $value;
}
// Retrieve the desired timezone from the request or default to 'UTC'
$timezone = request()->get('timezone', 'UTC');
return Carbon::parse($value)->setTimezone($timezone)->toIso8601String();
}
2022-09-20 21:59:52 +02:00
public function getIsClosedAttribute()
{
return $this->visibility === 'closed' || ($this->closes_at && now()->gt($this->closes_at));
2022-09-20 21:59:52 +02:00
}
public function getFormPendingSubmissionKeyAttribute()
{
if ($this->updated_at?->timestamp) {
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
return 'openform-' . $this->id . '-pending-submission-' . substr($this->updated_at?->timestamp, -6);
}
2024-02-23 11:54:12 +01:00
return null;
}
2022-09-20 21:59:52 +02:00
public function getMaxNumberOfSubmissionsReachedAttribute()
{
2024-02-23 11:54:12 +01:00
return $this->max_submissions_count && $this->max_submissions_count <= $this->submissions_count;
2022-09-20 21:59:52 +02:00
}
public function setClosedTextAttribute($value)
{
$this->attributes['closed_text'] = Purify::clean($value);
}
public function setMaxSubmissionsReachedTextAttribute($value)
{
$this->attributes['max_submissions_reached_text'] = Purify::clean($value);
}
public function getHasPasswordAttribute()
{
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
return !empty($this->password);
2022-09-20 21:59:52 +02:00
}
2023-12-15 12:43:05 +01:00
public function getMaxFileSizeAttribute()
{
2024-02-23 11:54:12 +01:00
return $this->remember('max_file_size', 15 * 60, function (): int {
2023-12-15 12:43:05 +01:00
return $this->workspace->max_file_size;
});
}
protected function removedProperties(): Attribute
{
2023-10-13 11:43:53 +02:00
return Attribute::make(
get: function ($value) {
return $value ? json_decode($value, true) : [];
}
);
2023-10-13 10:05:10 +02:00
}
2022-09-20 21:59:52 +02:00
/**
* Relationships
*/
public function workspace()
{
return $this->belongsTo(Workspace::class);
}
public function creator()
{
return $this->belongsTo(User::class, 'creator_id');
}
public function submissions()
{
return $this->hasMany(FormSubmission::class);
}
public function views()
{
return $this->hasMany(FormView::class);
}
public function statistics()
{
return $this->hasMany(FormStatistic::class);
}
public function zappierHooks()
{
return $this->hasMany(FormZapierWebhook::class);
}
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
public function integrations()
{
return $this->hasMany(FormIntegration::class);
}
2022-09-20 21:59:52 +02:00
/**
* Config/options
*/
public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->doNotGenerateSlugsOnUpdate()
->generateSlugsFrom(function (Form $form) {
Remove old code related to notifications (#363) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:46:29 +01:00
return $form->title . ' ' . Str::random(6);
})
2022-09-20 21:59:52 +02:00
->saveSlugsTo('slug');
}
public static function newFactory()
{
return FormFactory::new();
}
}