-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathUpdateLtiToolSettingRequest.php
More file actions
60 lines (55 loc) · 2.18 KB
/
UpdateLtiToolSettingRequest.php
File metadata and controls
60 lines (55 loc) · 2.18 KB
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
<?php
namespace App\Http\Requests\V1\LtiTool;
use Illuminate\Foundation\Http\FormRequest;
/**
* @author Asim Sarwar
* Date 11-10-2021
* Description Validation request class for update lti tool settings
* class UpdateLtiToolSetting
*/
class UpdateLtiToolSettingRequest 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()
{
$id = $this->route('lti_tool_setting');
$orgId = request('organization_id');
return [
'tool_name' => 'required|string|max:255|unique:lti_tool_settings,tool_name, ' . $id . ' ,id,deleted_at,NULL,organization_id,' . $orgId,
'tool_url' => 'required|url|max:255|unique:lti_tool_settings,tool_url, ' . $id . ' ,id,deleted_at,NULL,organization_id,' . $orgId,
'lti_version' => 'required|max:20',
'lti_tool_type_id' => 'required|exists:lti_tool_type,id|unique:lti_tool_settings,lti_tool_type_id, ' . $id . ' ,id,deleted_at,NULL,organization_id,' . $orgId,
'tool_consumer_key' => 'nullable|string|max:255|unique:lti_tool_settings,tool_consumer_key, ' . $id . ' ,id,deleted_at,NULL,organization_id,' . $orgId,
'tool_secret_key' => 'required_with:tool_consumer_key|max:255|unique:lti_tool_settings,tool_secret_key, ' . $id . ' ,id,deleted_at,NULL,organization_id,' . $orgId,
'tool_content_selection_url' => 'nullable|url|max:255',
'user_id' => 'required|exists:users,id',
'organization_id' => 'required|exists:organizations,id'
];
}
/**
* Set the custom validation message that apply to the request.
*
* @return array
*/
public function messages()
{
return [
'lti_tool_type_id.required' => 'The Tool Type field is required.',
'lti_tool_type_id.exists' => 'The selected Tool Type is invalid.',
'lti_tool_type_id.unique' => 'The Tool Type has already been taken.'
];
}
}