forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreServerDatabaseRequest.php
More file actions
61 lines (54 loc) · 1.43 KB
/
StoreServerDatabaseRequest.php
File metadata and controls
61 lines (54 loc) · 1.43 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
<?php
namespace Pterodactyl\Http\Requests\Api\Application\Servers\Databases;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
class StoreServerDatabaseRequest extends ApplicationApiRequest
{
/**
* @var string
*/
protected $resource = AdminAcl::RESOURCE_SERVER_DATABASES;
/**
* @var int
*/
protected $permission = AdminAcl::WRITE;
/**
* Validation rules for database creation.
*
* @return array
*/
public function rules(): array
{
return [
'database' => 'required|string|min:1|max:24',
'remote' => 'required|string|min:1',
'host' => 'required|integer|exists:database_hosts,id',
];
}
/**
* Return data formatted in the correct format for the service to consume.
*
* @return array
*/
public function validated()
{
return [
'database' => $this->input('database'),
'remote' => $this->input('remote'),
'database_host_id' => $this->input('host'),
];
}
/**
* Format error messages in a more understandable format for API output.
*
* @return array
*/
public function attributes()
{
return [
'host' => 'Database Host Server ID',
'remote' => 'Remote Connection String',
'database' => 'Database Name',
];
}
}