-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathSuborganizationSave.php
74 lines (69 loc) · 2.8 KB
/
SuborganizationSave.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace App\Http\Requests\V1;
use Illuminate\Foundation\Http\FormRequest;
use App\Rules\Lowercase;
class SuborganizationSave extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|string|max:255',
'description' => 'required|string|max:255',
'domain' => ['required', 'alpha_dash', 'min:2', 'max:255', 'unique:organizations,domain', new Lowercase],
'image' => 'required|max:255',
'favicon' => 'nullable|max:255',
'admins' => 'array|exists:App\User,id',
'visibility_type_id' => 'array|min:1|required',
'visibility_type_id.*' => 'integer|exists:App\Models\OrganizationVisibilityType,id',
'users' => 'array',
'users.*.user_id' => 'required_with:users.*.role_id|integer|exists:App\User,id',
'users.*.role_id' => 'required_with:users.*.user_id|integer|exists:App\Models\OrganizationRoleType,id',
'parent_id' => 'required|integer|exists:App\Models\Organization,id',
'self_registration' => 'boolean',
'account_id' => 'max:255',
'api_key' => 'max:255',
'unit_path' => 'max:255',
'noovo_client_id' => 'string|max:255',
'tos_type' => 'required|in:Parent,URL,Content',
'tos_url' => 'required_if:tos_type,==,URL|url|max:255',
'tos_content' => 'required_if:tos_type,==,Content|string|max:65000',
'privacy_policy_type' => 'required|in:Parent,URL,Content',
'privacy_policy_url' => 'required_if:privacy_policy_type,==,URL|url|max:255',
'privacy_policy_content' => 'required_if:privacy_policy_type,==,Content|string|max:65000',
'primary_color' => 'string|nullable|max:255',
'secondary_color' => 'string|nullable|max:255',
'tertiary_color' => 'string|nullable|max:255',
'primary_font_family' => 'string|nullable|max:255',
'secondary_font_family' => 'string|nullable|max:255',
'auto_approve' => 'boolean|nullable',
'activity_title_text' => 'string|nullable|max:255',
'activity_title_placeholder' => 'string|nullable|max:255'
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public function messages()
{
return [
'tos_type.in' => 'The ToS type should be Parent, URL OR Content',
'privacy_policy_type.in' => 'The privacy policy type should be Parent, URL OR Content',
];
}
}