-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathDownloadFileRequest.php
More file actions
71 lines (62 loc) · 1.8 KB
/
DownloadFileRequest.php
File metadata and controls
71 lines (62 loc) · 1.8 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
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Fleetbase\Http\Requests\Internal;
use Fleetbase\Http\Requests\FleetbaseRequest;
class DownloadFileRequest extends FleetbaseRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->session()->has('user');
}
/**
* Prepare the data for validation.
*
* Ensures route parameters are available for validation rules.
*/
protected function prepareForValidation(): void
{
if ($this->route('id')) {
$this->merge([
'id' => $this->route('id'),
]);
}
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'file' => ['required_without:id', 'uuid', 'exists:files,uuid'],
'id' => ['required_without:file', 'uuid', 'exists:files,uuid'],
'disk' => ['sometimes', 'string'],
];
}
/**
* Get the validation rules error messages.
*
* @return array
*/
public function messages()
{
return [
// Missing identifier
'id.required_without' => 'Please provide a file identifier.',
'file.required_without' => 'Please provide a file identifier.',
// Invalid format
'id.uuid' => 'The file identifier must be a valid UUID.',
'file.uuid' => 'The file identifier must be a valid UUID.',
// File not found
'id.exists' => 'The requested file does not exist.',
'file.exists' => 'The requested file does not exist.',
// Disk override
'disk.string' => 'The storage disk must be a valid string.',
];
}
}