Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php
10284 views
1
<?php
2
3
namespace Pterodactyl\Http\Requests\Admin\Servers\Databases;
4
5
use Illuminate\Validation\Rule;
6
use Illuminate\Database\Query\Builder;
7
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
8
9
class StoreServerDatabaseRequest extends AdminFormRequest
10
{
11
/**
12
* Validation rules for database creation.
13
*/
14
public function rules(): array
15
{
16
return [
17
'database' => [
18
'required',
19
'string',
20
'min:1',
21
'max:24',
22
Rule::unique('databases')->where(function (Builder $query) {
23
$query->where('database_host_id', $this->input('database_host_id') ?? 0);
24
}),
25
],
26
'max_connections' => 'nullable',
27
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
28
'database_host_id' => 'required|integer|exists:database_hosts,id',
29
];
30
}
31
}
32
33