Giant Update

This commit is contained in:
Wian Drs
2026-07-31 13:57:11 +07:00
parent f68d967c8b
commit b0d08211ec
112 changed files with 6674 additions and 3 deletions
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Topology;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class IndexTopologyRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'search' => ['nullable', 'string', 'max:255'],
'status' => ['nullable', 'string', 'max:30'],
'device_type_id' => ['nullable', 'integer', 'exists:topology_device_types,id'],
'link_type' => ['nullable', Rule::in(['fiber', 'wireless', 'ethernet', 'logical'])],
'bbox' => ['nullable', 'regex:/^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?$/'],
'page' => ['nullable', 'integer', 'min:1'],
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
'sort_by' => ['nullable', Rule::in(['id', 'code', 'name', 'status', 'category', 'link_type', 'installed_at', 'created_at'])],
'sort_direction' => ['nullable', Rule::in(['asc', 'desc'])],
];
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Requests\Topology;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreCustomerConnectionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'customer_id' => ['required', 'integer', 'exists:customers,id'],
'odp_node_id' => ['required', 'integer', 'exists:topology_nodes,id'],
'odp_port_id' => ['nullable', 'integer', 'exists:topology_ports,id'],
'drop_cable_link_id' => ['nullable', 'integer', 'exists:topology_links,id'],
'connected_at' => ['nullable', 'date'],
'status' => ['nullable', Rule::in(['active', 'inactive'])],
'metadata' => ['nullable', 'array'],
];
}
}
@@ -0,0 +1,89 @@
<?php
namespace App\Http\Requests\Topology;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreTopologyRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return match ($this->route()->defaults['topology_resource'] ?? null) {
'device-type' => [
...$this->tenantRule(),
'code' => ['required', 'string', 'max:50'],
'name' => ['required', 'string', 'max:255'],
'category' => ['required', Rule::in(['site', 'termination', 'closure', 'distribution', 'splitter', 'other'])],
'can_have_ports' => ['nullable', 'boolean'],
'can_have_splitters' => ['nullable', 'boolean'],
'icon' => ['nullable', 'string', 'max:100'],
'color' => ['nullable', 'regex:/^#[0-9a-fA-F]{6}$/'],
'status' => ['nullable', Rule::in(['active', 'inactive'])],
],
'node' => [
...$this->tenantRule(),
'device_type_id' => ['required', 'integer', 'exists:topology_device_types,id'],
'parent_node_id' => ['nullable', 'integer', 'exists:topology_nodes,id'],
'code' => ['required', 'string', 'max:100'],
'name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'status' => ['nullable', Rule::in(['active', 'inactive', 'maintenance', 'damaged'])],
'latitude' => ['required', 'numeric', 'between:-90,90'],
'longitude' => ['required', 'numeric', 'between:-180,180'],
'address' => ['nullable', 'string'],
'provinsi_id' => ['nullable', 'integer', 'exists:wilayah_provinsi,id'],
'kabupaten_id' => ['nullable', 'integer', 'exists:wilayah_kabupaten,id'],
'kecamatan_id' => ['nullable', 'integer', 'exists:wilayah_kecamatan,id'],
'desa_id' => ['nullable', 'integer', 'exists:wilayah_desa,id'],
'capacity' => ['nullable', 'integer', 'min:0'],
'installed_at' => ['nullable', 'date'],
'diagram_x' => ['nullable', 'numeric'],
'diagram_y' => ['nullable', 'numeric'],
'metadata' => ['nullable', 'array'],
],
'link' => [
...$this->tenantRule(),
'source_node_id' => ['required', 'integer', 'exists:topology_nodes,id', 'different:target_node_id'],
'source_port_id' => ['nullable', 'integer', 'exists:topology_ports,id'],
'target_node_id' => ['required', 'integer', 'exists:topology_nodes,id'],
'target_port_id' => ['nullable', 'integer', 'exists:topology_ports,id'],
'code' => ['required', 'string', 'max:100'],
'name' => ['required', 'string', 'max:255'],
'link_type' => ['required', Rule::in(['fiber', 'wireless', 'ethernet', 'logical'])],
'fiber_type' => ['nullable', 'string', 'max:50'],
'core_count' => ['nullable', 'integer', 'min:1'],
'cable_length' => ['nullable', 'numeric', 'min:0'],
'measured_length' => ['nullable', 'numeric', 'min:0'],
'path_geojson' => ['nullable', 'array'],
'path_geojson.type' => ['required_with:path_geojson', Rule::in(['LineString'])],
'path_geojson.coordinates' => ['required_with:path_geojson', 'array', 'min:2'],
'path_geojson.coordinates.*' => ['array', 'size:2'],
'path_geojson.coordinates.*.*' => ['numeric'],
'status' => ['nullable', Rule::in(['active', 'inactive', 'maintenance', 'damaged'])],
'installed_at' => ['nullable', 'date'],
'metadata' => ['nullable', 'array'],
],
'port' => [
'name' => ['required', 'string', 'max:100'],
'port_number' => ['required', 'integer', 'min:1'],
'port_type' => ['required', Rule::in(['fiber', 'ethernet', 'pon', 'uplink', 'splitter', 'other'])],
'direction' => ['required', Rule::in(['input', 'output', 'bidirectional'])],
'capacity' => ['nullable', 'integer', 'min:1'],
'status' => ['nullable', Rule::in(['available', 'used', 'reserved', 'damaged'])],
'metadata' => ['nullable', 'array'],
],
default => [],
};
}
private function tenantRule(): array
{
return ['tenant_id' => ['nullable', 'integer', 'exists:tenants,id']];
}
}
@@ -0,0 +1,18 @@
<?php
namespace App\Http\Requests\Topology;
class UpdateTopologyRequest extends StoreTopologyRequest
{
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();
}
}