This commit is contained in:
baodev0
2026-07-01 10:51:05 +07:00
parent 914e96138a
commit 3bb59feba3
43 changed files with 1680 additions and 28 deletions
@@ -0,0 +1,36 @@
<?php
namespace Modules\DomainFluctuation\App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Modules\DomainFluctuation\App\DTOs\DomainFluctuationFilterDTO;
class IndexDomainFluctuationRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'term_id' => ['nullable', 'integer'],
'keyword' => ['nullable', 'string', 'max:255'],
'ownerType' => ['nullable', 'in:C,T'],
'status' => ['nullable', 'integer', 'in:0,1'],
'action' => ['nullable', 'string', 'max:100'],
'from' => ['nullable', 'integer'],
'to' => ['nullable', 'integer'],
'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
'page' => ['nullable', 'integer', 'min:1'],
'sort_by' => ['nullable', 'in:id,domainName,registeredDate,expiredDate,actionDate,created_at'],
'sort_dir' => ['nullable', 'in:asc,desc'],
];
}
public function toDTO(): DomainFluctuationFilterDTO
{
return DomainFluctuationFilterDTO::fromArray($this->validated());
}
}
@@ -0,0 +1,75 @@
<?php
namespace Modules\DomainFluctuation\App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Modules\DomainFluctuation\App\DTOs\DomainFluctuationDTO;
class StoreDomainFluctuationRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'domainName' => ['required', 'string', 'max:255'],
'term_id' => ['required', 'integer', 'exists:domain_fluctuation_terms,id'],
'ownerName' => ['required', 'string', 'max:255'],
'ownerType' => ['required', 'in:C,T'],
'address' => ['required', 'string'],
'countryCode' => ['required', 'string', 'max:10'],
'adminName' => ['required', 'string', 'max:255'],
'phone' => ['required', 'string', 'max:50'],
'email' => ['required', 'email', 'max:255'],
'registeredDate' => ['required'],
'expiredDate' => ['required'],
'cityName' => ['nullable', 'string', 'max:255'],
'cityCode' => ['nullable', 'string', 'max:50'],
'districtName' => ['nullable', 'string', 'max:255'],
'wardName' => ['nullable', 'string', 'max:255'],
'fax' => ['nullable', 'string', 'max:50'],
'icannRegistrarName' => ['nullable', 'string', 'max:255'],
'icannRegistrarTradeName' => ['nullable', 'string', 'max:255'],
'businessCode' => ['nullable', 'string', 'max:100'],
'eidCode' => ['nullable', 'string', 'max:100'],
'personalId' => ['nullable', 'string', 'max:50'],
'birthDate' => ['nullable', 'string', 'max:20'],
'isAgentManager' => ['nullable', 'boolean'],
'action' => ['nullable', 'string', 'max:100'],
'actionReason' => ['nullable', 'string'],
'actionSource' => ['nullable', 'string', 'max:100'],
'actionDate' => ['nullable'],
'note' => ['nullable', 'string'],
'ianaNumber' => ['nullable', 'integer'],
'status' => ['nullable', 'integer', 'in:0,1'],
];
}
public function messages(): array
{
return [
'domainName.required' => 'Tên miền là bắt buộc',
'term_id.required' => 'Đợt khai báo là bắt buộc',
'term_id.exists' => 'Đợt khai báo không tồn tại',
'ownerName.required' => 'Tên chủ sở hữu là bắt buộc',
'ownerType.required' => 'Loại chủ sở hữu là bắt buộc',
'ownerType.in' => 'Loại chủ sở hữu phải là C (cá nhân) hoặc T (tổ chức)',
'registeredDate.required' => 'Ngày đăng ký là bắt buộc',
'expiredDate.required' => 'Ngày hết hạn là bắt buộc',
'address.required' => 'Địa chỉ là bắt buộc',
'countryCode.required' => 'Mã quốc gia là bắt buộc',
'adminName.required' => 'Tên quản trị là bắt buộc',
'phone.required' => 'Số điện thoại là bắt buộc',
'email.required' => 'Email là bắt buộc',
'email.email' => 'Email không hợp lệ',
];
}
public function toDTO(): DomainFluctuationDTO
{
return DomainFluctuationDTO::fromArray($this->validated());
}
}
@@ -0,0 +1,40 @@
<?php
namespace Modules\DomainFluctuation\App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Modules\DomainFluctuation\App\DTOs\DomainFluctuationTermDTO;
class StoreTermRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'term_name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'date_create' => ['nullable'],
'status' => ['nullable', 'boolean'],
'type' => ['nullable', 'in:vnnic_06,vnnic_07'],
];
}
public function messages(): array
{
return [
'term_name.required' => 'Tên đợt khai báo là bắt buộc',
];
}
public function toDTO(int $userId): DomainFluctuationTermDTO
{
return DomainFluctuationTermDTO::fromArray(array_merge(
$this->validated(),
['user_id' => $userId]
));
}
}
@@ -0,0 +1,20 @@
<?php
namespace Modules\DomainFluctuation\App\Http\Requests;
use Modules\DomainFluctuation\App\DTOs\DomainFluctuationDTO;
class UpdateDomainFluctuationRequest extends StoreDomainFluctuationRequest
{
public function rules(): array
{
return array_merge(parent::rules(), [
'term_id' => ['sometimes', 'integer', 'exists:domain_fluctuation_terms,id'],
]);
}
public function toDTO(): DomainFluctuationDTO
{
return DomainFluctuationDTO::fromArray($this->validated());
}
}