Skip to content

Instantly share code, notes, and snippets.

@Gummibeer
Created June 21, 2024 15:10
Show Gist options
  • Save Gummibeer/889c4f6bd30aa0a046f41ce63867a6c0 to your computer and use it in GitHub Desktop.
Save Gummibeer/889c4f6bd30aa0a046f41ce63867a6c0 to your computer and use it in GitHub Desktop.
<?php
class CreateTenantRequest extends Formrequest
{
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'settings' => ['required', 'array', 'contrains:timezone,currency'],
];
}
}
@Gummibeer
Copy link
Author

Gummibeer commented Jun 21, 2024

Your HTML form will look like:

  • Name
  • Settings
    • Timezone
    • Currency
    • IP
    • Domain
    • Database

The contrains validation will ensure that Timezone and Currency have to be always ticked (be present in the settings array as value).

The request payload should look like:

{
    "name": "Tenant name",
    "settings": [
        'timezone',
        'currency',
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment