forked from admin/services_core
big update base struktur tahap 1
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Nas;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class IndexNasResourceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
'status' => ['nullable', Rule::in(['active', 'inactive'])],
|
||||
'connection_type' => ['nullable', Rule::in(['api', 'radius'])],
|
||||
'service_type' => ['nullable', Rule::in(['ppp', 'hotspot', 'radius'])],
|
||||
'page' => ['nullable', 'integer', 'min:1'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'sort_by' => ['nullable', Rule::in(['id', 'name', 'host', 'connection_type', 'service_type', 'vendor', 'device_type', 'status', 'created_at'])],
|
||||
'sort_direction' => ['nullable', Rule::in(['asc', 'desc'])],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Nas;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreNasResourceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return array_merge($this->commonRules(), match ($this->route()->defaults['nas_resource'] ?? null) {
|
||||
'mikrotik' => [
|
||||
'connection_type' => ['required', Rule::in(['api', 'radius'])],
|
||||
'host' => ['required', 'string', 'max:255'],
|
||||
'api_port' => ['nullable', 'integer', 'between:1,65535'],
|
||||
'api_username' => ['nullable', 'string', 'max:255'],
|
||||
'api_password' => ['nullable', 'string', 'max:1000'],
|
||||
'radius_auth_port' => ['nullable', 'integer', 'between:1,65535'],
|
||||
'radius_accounting_port' => ['nullable', 'integer', 'between:1,65535'],
|
||||
'radius_secret' => ['nullable', 'string', 'max:1000'],
|
||||
'timeout' => ['nullable', 'integer', 'between:1,300'],
|
||||
],
|
||||
'package-profile' => [
|
||||
'service_type' => ['required', Rule::in(['ppp', 'hotspot', 'radius'])],
|
||||
'external_profile_name' => ['nullable', 'string', 'max:255'],
|
||||
'download_kbps' => ['nullable', 'integer', 'min:0'],
|
||||
'upload_kbps' => ['nullable', 'integer', 'min:0'],
|
||||
'local_address' => ['nullable', 'string', 'max:255'],
|
||||
'remote_address_pool' => ['nullable', 'string', 'max:255'],
|
||||
'session_timeout' => ['nullable', 'integer', 'min:0'],
|
||||
'idle_timeout' => ['nullable', 'integer', 'min:0'],
|
||||
'shared_users' => ['nullable', 'integer', 'min:1'],
|
||||
'price' => ['nullable', 'numeric', 'min:0'],
|
||||
],
|
||||
'olt' => [
|
||||
'vendor' => ['nullable', 'string', 'max:255'],
|
||||
'model' => ['nullable', 'string', 'max:255'],
|
||||
'host' => ['required', 'string', 'max:255'],
|
||||
'snmp_port' => ['nullable', 'integer', 'between:1,65535'],
|
||||
'snmp_version' => ['required', Rule::in(['v1', 'v2c', 'v3'])],
|
||||
'community' => ['nullable', 'string', 'max:1000'],
|
||||
'security_level' => ['nullable', Rule::in(['noAuthNoPriv', 'authNoPriv', 'authPriv'])],
|
||||
'security_name' => ['nullable', 'string', 'max:255'],
|
||||
'auth_protocol' => ['nullable', Rule::in(['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384', 'SHA512'])],
|
||||
'auth_password' => ['nullable', 'string', 'max:1000'],
|
||||
'privacy_protocol' => ['nullable', Rule::in(['DES', 'AES', 'AES192', 'AES256'])],
|
||||
'privacy_password' => ['nullable', 'string', 'max:1000'],
|
||||
'timeout' => ['nullable', 'integer', 'between:1,300'],
|
||||
],
|
||||
'webfig' => [
|
||||
'device_type' => ['nullable', 'string', 'max:100'],
|
||||
'url' => ['required', 'url:http,https', 'max:2000'],
|
||||
'username' => ['nullable', 'string', 'max:255'],
|
||||
'password' => ['nullable', 'string', 'max:1000'],
|
||||
],
|
||||
default => [],
|
||||
});
|
||||
}
|
||||
|
||||
protected function commonRules(): array
|
||||
{
|
||||
return [
|
||||
'tenant_id' => ['nullable', 'integer', 'exists:tenants,id'],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'status' => ['nullable', Rule::in(['active', 'inactive'])],
|
||||
'notes' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Nas;
|
||||
|
||||
class UpdateNasResourceRequest extends StoreNasResourceRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return collect(parent::rules())
|
||||
->map(function ($rules) {
|
||||
$rules = is_array($rules) ? $rules : [$rules];
|
||||
if (($index = array_search('required', $rules, true)) !== false) {
|
||||
$rules[$index] = 'sometimes';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
})
|
||||
->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user