update fix deadcode, security

This commit is contained in:
baodev0
2026-09-28 08:26:29 +07:00
parent 3af59bd9c5
commit 82080b5b84
452 changed files with 4857 additions and 26289 deletions
-34
View File
@@ -1,34 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class AddOnRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required',
'price' => 'required|numeric',
'min' => 'required|numeric',
'max' => 'required|numeric',
'step' => 'required|numeric',
'prefix' => 'required',
'type_id' => 'required|numeric'
];
}
}
-30
View File
@@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class AddPayRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'userid' => 'required|numeric|not__in:0',
'action' => 'required',
'amount' => 'required|numeric|not__in:0',
];
}
}
-34
View File
@@ -1,34 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CouponRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'code' => 'required',
'start' => 'required',
'end' => 'required',
'count' => 'required',
'type' => 'required',
'discount' => 'required',
'status' => 'required'
];
}
}
@@ -1,21 +0,0 @@
<?php
namespace App\Http\Requests\Domain;
use Illuminate\Foundation\Http\FormRequest;
class DomainRemoveRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'ids' => 'required|array|min:1',
'ids.*' => 'required|integer|exists:dns_manager_domain,id',
];
}
}
@@ -1,23 +0,0 @@
<?php
namespace App\Http\Requests\Domain;
use Illuminate\Foundation\Http\FormRequest;
class DomainRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'domain_name' => 'required|string|max:255',
'dns_manager_server_id' => 'required|integer|exists:dns_manager_servers,id',
'user_id' => 'nullable|array',
'user_id.*' => 'integer|exists:customers,id',
];
}
}
-34
View File
@@ -1,34 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class DomainRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required',
'price' => 'required',
'renewal' => 'required',
'transfer' => 'required',
'type_id' => 'required',
'auto_reg' => 'required',
'status' => 'required'
];
}
}
-31
View File
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\Group;
use Illuminate\Foundation\Http\FormRequest;
class GroupRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required',
'type_id' => 'required',
'status' => 'nullable',
'grid' => 'required',
];
}
}
-28
View File
@@ -1,28 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class HostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}
-35
View File
@@ -1,35 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class HostingRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'product_id' => 'required',
'next_due_date' => 'required',
'next_payment' => 'required',
'name' => 'required',
'module_server_id' => 'required',
'user' => 'required',
'password' => 'required',
'status' => 'required'
];
}
}
-34
View File
@@ -1,34 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MenuRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'title' => 'required',
'slug' => 'nullable',
'route_name' => 'nullable',
'parent_id' => 'nullable',
'icon' => 'required',
'sort_by' => 'required',
'is_active' => 'nullable',
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\ModuleDNS;
use Illuminate\Foundation\Http\FormRequest;
class CreateDNSRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|ip|ipv4',
'user' => 'required',
'password' => 'required',
'status' => 'required'
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\ModuleDNS;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDNSRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|ip|ipv4',
'user' => 'required',
'password' => 'nullable',
'status' => 'required'
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\ModuleHosting;
use Illuminate\Foundation\Http\FormRequest;
class CreateHostingRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|ip|ipv4',
'user' => 'required',
'password' => 'required',
'status' => 'required'
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\ModuleHosting;
use Illuminate\Foundation\Http\FormRequest;
class UpdateHostingRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|ip|ipv4',
'user' => 'required',
'password' => 'nullable',
'status' => 'required'
];
}
}
-55
View File
@@ -1,55 +0,0 @@
<?php
namespace App\Http\Requests\Order;
use Illuminate\Foundation\Http\FormRequest;
class OrderRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'server_name' => 'required|string|max:255|unique:order__order_item,server_name',
'product_id' => 'required|integer',
'product_type' => 'required|integer',
'months' => 'required|integer',
'cart_id' => 'required|integer|exists:carts,id',
'os_id' => 'required|integer|exists:os,id',
'addons' => 'nullable|array',
'addons.*.qty' => 'nullable|integer|min:0',
'addons.*.price' => 'nullable|integer|min:0',
'totalPrice' => 'required|integer|min:0',
];
}
public function messages(): array
{
return [
'server_name.required' => 'Vui lòng bổ sung thêm tên miền!',
'server_name.string' => 'Tên miền phải là chuỗi ký tự.',
'server_name.max' => 'Tên miền không được vượt quá 255 ký tự.',
'server_name.unique' => 'Tên miền này đã được sử dụng, vui lòng chọn tên khác.',
'product_type.required' => 'Loại sản phẩm là bắt buộc.',
'product_type.integer' => 'Loại sản phẩm phải là số nguyên.',
'os_id.required' => 'Vui lòng chọn hệ điều hành!',
'os_id.integer' => 'Hệ điều hành phải là số nguyên.',
'os_id.exists' => 'Hệ điều hành không tồn tại.',
'addons.*.qty.min' => 'Số lượng addon phải lớn hơn hoặc bằng 0.',
'addons.*.price.min' => 'Giá addon phải lớn hơn hoặc bằng 0.',
'cart_id.required' => 'Mã giỏ hàng là bắt buộc',
'totalPrice.required' => 'Tổng giá là bắt buộc.',
'totalPrice.integer' => 'Tổng giá phải là số nguyên.',
'totalPrice.min' => 'Tổng giá phải lớn hơn hoặc bằng 0.',
];
}
}
@@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class DatacenterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required',
'vcenter_id' => 'required',
'datacenter_id' => 'required'
];
}
}
@@ -1,33 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class DatastoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'module_host_id' => 'required',
'name' => 'required',
'datastore' => 'required',
'type' => 'required',
'space' => 'required',
'status' => 'required'
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class FolderRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'module_datacenter_id' => 'required',
'name' => 'required',
'folder' => 'required',
'type' => 'required'
];
}
}
-32
View File
@@ -1,32 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class HostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'module_datacenter_id' => 'required',
'name' => 'required',
'host_id' => 'required',
'template' => 'required',
'console' => 'required'
];
}
}
-38
View File
@@ -1,38 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class IPRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'module_host_id' => 'required',
'module_network_id' => 'required',
'gateway' => 'required',
'option_selected' => 'required',
'netmask' => 'required',
'dns' => 'required',
'from' => 'nullable',
'to' => 'nullable',
'list-ip' => 'nullable',
'ip' => 'nullable',
'status' => 'nullable',
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class NetworkRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'module_host_id' => 'required',
'name' => 'required',
'network' => 'required',
'type' => 'required',
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class OsGroupRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required',
'module_host_id' => 'required',
'thumbnail' => 'required',
'status' => 'required'
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\Package;
use Illuminate\Foundation\Http\FormRequest;
class OsVersionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'version' => 'required',
'os_group_id' => 'required',
'template_id' => 'nullable',
'status' => 'required'
];
}
}
-30
View File
@@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class PostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required',
'slug' => 'required',
'status' => 'required'
];
}
}
@@ -1,208 +0,0 @@
<?php
namespace App\Http\Requests\Product;
use App\Enums\Product\ProductBillingCycle;
use App\Models\Product;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
class ProductRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$productId = $this->route('id');
$rules = [
'product_type' => ['required', 'string', 'max:50'],
'product_categories_id' => ['required', 'exists:product_categories,id'],
'name' => [
'required',
'string',
'max:255',
function ($attribute, $value, $fail) use ($productId) {
$slug = Str::slug($value);
$query = Product::where('slug', $slug);
// Exclude current product when updating
if ($productId) {
$query->where('id', '!=', $productId);
}
if ($query->exists()) {
$fail('Tên sản phẩm đã tồn tại. Vui lòng chọn tên khác.');
}
},
],
'short_description' => ['nullable', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'thumbnail' => ['nullable', 'string', 'max:255'],
'gallery' => ['nullable', 'array'],
'gallery.*' => ['nullable', 'string', 'max:255'],
'stock' => ['nullable', 'integer', 'min:0'],
'is_unlimited' => ['boolean'],
'cpu' => ['nullable', 'string', 'max:255'],
'ram' => ['nullable', 'string', 'max:255'],
'gpu' => ['nullable', 'string', 'max:255'],
'disk' => ['nullable', 'string', 'max:255'],
'bandwidth' => ['nullable', 'string', 'max:255'],
'features' => ['nullable', 'json'],
'metadata' => ['nullable', 'json'],
'setup_fee' => ['nullable', 'numeric', 'min:0'],
'trial_days' => ['nullable', 'integer', 'min:0'],
'currency' => ['nullable', 'string', 'max:10'],
'is_active' => ['boolean'],
'sort_order' => ['nullable', 'integer'],
'published_at' => ['nullable', 'date'],
// OS versions (pivot table os_product) - for VPS
'os_ids' => ['nullable', 'array'],
'os_ids.*' => ['exists:os,id'],
// Control Panels (pivot table product_control_panel) - for Hosting
'control_panel_ids' => ['nullable', 'array'],
'control_panel_ids.*' => ['exists:control_panels,id'],
'control_panel_price_modifiers' => ['nullable', 'array'],
'control_panel_price_modifiers.*' => ['nullable', 'numeric', 'min:0'],
'control_panel_default' => ['nullable', 'exists:control_panels,id'],
// Images
'thumbnail' => ['nullable', 'string', 'max:255'],
'gallery' => ['nullable', 'array'],
'gallery.*' => ['nullable', 'string', 'max:255'],
// Pricing cycles (table product_pricings)
'pricing' => ['nullable', 'array'],
];
// Add dynamic validation for each billing cycle
foreach (ProductBillingCycle::cases() as $cycle) {
$cycleKey = $cycle->value;
$rules["pricing.{$cycleKey}.enabled"] = ['nullable', 'boolean'];
$rules["pricing.{$cycleKey}.price"] = ['nullable', 'numeric', 'min:0'];
$rules["pricing.{$cycleKey}.price_sale"] = [
'nullable',
'numeric',
'min:0',
"required_with:pricing.{$cycleKey}.price_sale_check",
function ($attribute, $value, $fail) use ($cycleKey) {
$price = $this->input("pricing.{$cycleKey}.price");
// price_sale requires price to be set first
if ($value !== null && $value !== '' && (empty($price) || $price <= 0)) {
$fail("Bạn phải nhập giá gốc trước khi nhập giá khuyến mãi cho {$cycleKey}.");
return;
}
// price_sale must be less than price
if ($value !== null && $value !== '' && $price !== null && $value >= $price) {
$fail("Giá khuyến mãi phải nhỏ hơn giá gốc cho {$cycleKey}.");
}
},
];
}
return $rules;
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'product_type.required' => 'Vui lòng chọn loại sản phẩm.',
'product_type.string' => 'Loại sản phẩm phải là chuỗi ký tự.',
'product_type.max' => 'Loại sản phẩm không được vượt quá 50 ký tự.',
'product_categories_id.required' => 'Vui lòng chọn danh mục sản phẩm.',
'product_categories_id.exists' => 'Danh mục sản phẩm không hợp lệ.',
'name.required' => 'Vui lòng nhập tên sản phẩm.',
'name.string' => 'Tên sản phẩm phải là chuỗi ký tự.',
'name.max' => 'Tên sản phẩm không được vượt quá 255 ký tự.',
'short_description.string' => 'Mô tả ngắn phải là chuỗi ký tự.',
'short_description.max' => 'Mô tả ngắn không được vượt quá 255 ký tự.',
'description.string' => 'Mô tả phải là chuỗi ký tự.',
'thumbnail.string' => 'Đường dẫn ảnh đại diện phải là chuỗi ký tự.',
'thumbnail.max' => 'Đường dẫn ảnh đại diện không được vượt quá 255 ký tự.',
'gallery.array' => 'Thư viện ảnh không hợp lệ.',
'gallery.*.string' => 'Đường dẫn ảnh trong thư viện phải là chuỗi ký tự.',
'gallery.*.max' => 'Đường dẫn ảnh trong thư viện không được vượt quá 255 ký tự.',
'stock.integer' => 'Số lượng tồn kho phải là số nguyên.',
'stock.min' => 'Số lượng tồn kho không được âm.',
'is_unlimited.boolean' => 'Giá trị không giới hạn không hợp lệ.',
'cpu.string' => 'CPU phải là chuỗi ký tự.',
'cpu.max' => 'CPU không được vượt quá 255 ký tự.',
'ram.string' => 'RAM phải là chuỗi ký tự.',
'ram.max' => 'RAM không được vượt quá 255 ký tự.',
'gpu.string' => 'GPU phải là chuỗi ký tự.',
'gpu.max' => 'GPU không được vượt quá 255 ký tự.',
'disk.string' => 'Dung lượng ổ cứng phải là chuỗi ký tự.',
'disk.max' => 'Dung lượng ổ cứng không được vượt quá 255 ký tự.',
'bandwidth.string' => 'Băng thông phải là chuỗi ký tự.',
'bandwidth.max' => 'Băng thông không được vượt quá 255 ký tự.',
'features.json' => 'Tính năng phải là định dạng JSON hợp lệ.',
'metadata.json' => 'Metadata phải là định dạng JSON hợp lệ.',
'setup_fee.numeric' => 'Phí cài đặt phải là số.',
'setup_fee.min' => 'Phí cài đặt không được âm.',
'trial_days.integer' => 'Số ngày dùng thử phải là số nguyên.',
'trial_days.min' => 'Số ngày dùng thử không được âm.',
'currency.string' => 'Đơn vị tiền tệ phải là chuỗi ký tự.',
'currency.max' => 'Đơn vị tiền tệ không được vượt quá 10 ký tự.',
'is_active.boolean' => 'Trạng thái kích hoạt không hợp lệ.',
'sort_order.integer' => 'Thứ tự sắp xếp phải là số nguyên.',
'published_at.date' => 'Ngày xuất bản không hợp lệ.',
'os_ids.array' => 'Danh sách hệ điều hành không hợp lệ.',
'os_ids.*.exists' => 'Hệ điều hành được chọn không tồn tại.',
'control_panel_ids.array' => 'Danh sách Control Panel không hợp lệ.',
'control_panel_ids.*.exists' => 'Control Panel được chọn không tồn tại.',
'control_panel_price_modifiers.array' => 'Danh sách phụ phí Control Panel không hợp lệ.',
'control_panel_price_modifiers.*.numeric' => 'Phụ phí Control Panel phải là số.',
'control_panel_price_modifiers.*.min' => 'Phụ phí Control Panel không được âm.',
'control_panel_default.exists' => 'Control Panel mặc định không tồn tại.',
'pricing.array' => 'Thông tin giá không hợp lệ.',
'pricing.*.price.numeric' => 'Giá phải là số.',
'pricing.*.price.min' => 'Giá không được âm.',
'pricing.*.price_sale.numeric' => 'Giá khuyến mãi phải là số.',
'pricing.*.price_sale.min' => 'Giá khuyến mãi không được âm.',
];
}
}
@@ -1,87 +0,0 @@
<?php
namespace App\Http\Requests\ProductCategories;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProductCategoryRequest extends FormRequest
{
/**
* Xác định quyền truy cập
*/
public function authorize(): bool
{
return true; // Quan trọng: phải true
}
/**
* Rules validate
*/
public function rules(): array
{
$categoryId = $this->route('id');
// hoặc: $this->route('product_category')
return [
'name' => [
'required',
'string',
'max:255',
],
'slug' => [
'nullable',
'string',
'max:255',
Rule::unique('product_categories', 'slug')
->ignore($categoryId),
],
'parent_id' => [
'nullable',
'integer',
'exists:product_categories,id',
],
'is_active' => [
'nullable',
'boolean',
],
'sort_order' => [
'nullable',
'integer',
'min:0',
],
];
}
/**
* Chuẩn hóa dữ liệu trước khi validate
*/
protected function prepareForValidation(): void
{
$this->merge([
'slug' => $this->slug
? \Str::slug($this->slug)
: \Str::slug($this->name),
'is_active' => $this->has('is_active')
? (bool) $this->is_active
: true,
]);
}
/**
* Custom message (tuỳ chọn)
*/
public function messages(): array
{
return [
'name.required' => 'Tên danh mục không được để trống.',
'slug.unique' => 'Slug đã tồn tại.',
'parent_id.exists' => 'Danh mục cha không tồn tại.',
];
}
}
@@ -1,39 +0,0 @@
<?php
namespace App\Http\Requests\Recharge;
use Illuminate\Foundation\Http\FormRequest;
class RechargeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'total_amount' => 'required|numeric|min:200000',
'bankCode' => 'nullable|string',
];
}
public function messages()
{
return [
'total_amount.required' => 'Vui lòng nhập số tiền cần nạp.',
'total_amount.numeric' => 'Số tiền phải là một số.',
'total_amount.min' => 'Số tiền nạp vui lòng lớn hơn hoặc bằng 200.000vnđ',
];
}
}
@@ -1,21 +0,0 @@
<?php
namespace App\Http\Requests\Record;
use Illuminate\Foundation\Http\FormRequest;
class RecordRemoveRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'ids' => 'required|array|min:1',
'ids.*' => 'required|integer|exists:dns_manager_ns,id',
];
}
}
@@ -1,21 +0,0 @@
<?php
namespace App\Http\Requests\Server;
use Illuminate\Foundation\Http\FormRequest;
class ServerRemoveRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'ids' => 'required|array|min:1',
'ids.*' => 'required|integer|exists:dns_manager_servers,id',
];
}
}
@@ -1,24 +0,0 @@
<?php
namespace App\Http\Requests\Server;
use Illuminate\Foundation\Http\FormRequest;
class ServerRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'ip_address' => 'required|string|max:255',
'username' => 'required|string|max:255',
'password' => 'required|string|max:255',
'status' => 'nullable|string|in:activated,Stopped',
];
}
}
@@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Shop;
use Illuminate\Foundation\Http\FormRequest;
class AddToCartRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'product_id' => 'required|integer|min:1',
'type_id' => 'required|integer|min:1',
'product_price' => 'required|numeric|min:0',
];
}
/**
* Get custom error messages for validation rules.
*/
public function messages(): array
{
return [
'product_id.required' => 'Yêu cầu không hợp lệ!',
'product_id.integer' => 'ID sản phẩm không hợp lệ!',
'product_id.min' => 'ID sản phẩm không hợp lệ!',
'type_id.required' => 'Yêu cầu không hợp lệ!',
'type_id.integer' => 'ID loại sản phẩm không hợp lệ!',
'type_id.min' => 'ID loại sản phẩm không hợp lệ!',
'product_price.required' => 'Giá sản phẩm không được để trống!',
'product_price.numeric' => 'Giá sản phẩm phải là số!',
'product_price.min' => 'Giá sản phẩm không hợp lệ!',
];
}
}
-30
View File
@@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class TicketReplyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'ticket_id' => 'required',
'customer_id' => 'required',
'message' => 'required'
];
}
}
-28
View File
@@ -1,28 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class TicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}
@@ -1,53 +0,0 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class UserRegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => 'required|email|unique:customers',
'firstname' => 'required',
'lastname' => 'required',
'password' => 'required|min:8',
'phone' => 'required|unique:customers'
];
}
public function messages()
{
return [
'email' => [
'required' => 'Vui lòng nhập địa chỉ email',
'email' => 'Địa chỉ email không hợp lệ',
'unique' => 'Email này đã tồn tại'
],
'firstname.required' => 'Vui lòng nhập tên của bạn',
'lastname.required' => 'Vui lòng nhập họ của bạn',
'password' => [
'required' => 'Mật khẩu không được để trống',
'min' => 'Mật khẩu tối thiểu 8 ký tự'
],
'phone' => [
'required' => 'Số điện thoại là bắt buộc',
'unique' => 'Số điện thoại đã tồn tại'
]
];
}
}
@@ -1,60 +0,0 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class UserStoreInformation extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'firstname' => 'required',
'lastname' => 'required',
'email' => 'nullable|email|unique:customers,email',
'address' => 'nullable',
'phone' => 'required',
'gender' => 'nullable',
'company' => 'nullable',
'cccd' => 'nullable',
'front_cccd' => 'nullable',
'back_cccd' => 'nullable'
];
}
public function messages(): array
{
return [
'firstname.required' => 'Vui lòng nhập họ.',
'lastname.required' => 'Vui lòng nhập tên.',
'email.email' => 'Email không đúng định dạng.',
'address.string' => 'Địa chỉ không hợp lệ.',
'phone.required' => 'Vui lòng nhập số điện thoại.',
'gender.in' => 'Giới tính không hợp lệ.',
'company.string' => 'Tên công ty không hợp lệ.',
'cccd.required' => 'Vui lòng nhập số căn cước công dân.',
'cccd.digits' => 'Số căn cước công dân phải gồm 12 chữ số.',
'front_cccd.required' => 'Vui lòng tải lên hình ảnh mặt trước căn cước công dân.',
'front_cccd.image' => 'Tệp mặt trước CCCD phải là hình ảnh.',
'front_cccd.mimes' => 'Ảnh mặt trước CCCD phải có định dạng: jpeg, png, jpg.',
'front_cccd.max' => 'Ảnh mặt trước CCCD không được vượt quá 2MB.',
'back_cccd.required' => 'Vui lòng tải lên hình ảnh mặt sau căn cước công dân.',
'back_cccd.image' => 'Tệp mặt sau CCCD phải là hình ảnh.',
'back_cccd.mimes' => 'Ảnh mặt sau CCCD phải có định dạng: jpeg, png, jpg.',
'back_cccd.max' => 'Ảnh mặt sau CCCD không được vượt quá 2MB.',
];
}
}
-37
View File
@@ -1,37 +0,0 @@
<?php
namespace App\Http\Requests\VM;
use Illuminate\Foundation\Http\FormRequest;
class SnapShotRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'product_id' => 'required|string',
'name' => 'nullable|string|max:100|regex:/^[a-zA-Z0-9_-]+$/',
];
}
public function messages(): array
{
return [
'product_id.required' => 'Máy ảo không tồn tại',
'name.regex' => 'Tên snapshot không hợp lệ',
];
}
}
-39
View File
@@ -1,39 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class VmwareRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'product_id' => 'required',
'next_due_date' => 'required',
'next_payment' => 'required',
'name' => 'required',
'user' => 'required',
'password' => 'required',
'status' => 'required',
'ip' => 'required|ip|ipv4',
'os_version' => 'required',
'vmware_id' => 'required',
'hostname' => 'required',
'port' => 'required'
];
}
}
-62
View File
@@ -1,62 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class WhoisRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'domain' => [
'required',
'string',
'max:255',
'regex:/^[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)*$/'
]
];
}
/**
* Get custom validation messages.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'domain.required' => __('Domain name is required.'),
'domain.string' => __('Domain name must be a string.'),
'domain.max' => __('Domain name must not exceed 255 characters.'),
'domain.regex' => __('Please enter a valid domain name format.'),
];
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
public function attributes(): array
{
return [
'domain' => __('domain name'),
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\vCenter;
use Illuminate\Foundation\Http\FormRequest;
class CreatevCenterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'host' => 'required|ip|ipv4',
'user' => 'required',
'password' => 'required',
'status' => 'required'
];
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Http\Requests\vCenter;
use Illuminate\Foundation\Http\FormRequest;
class UpdatevCenterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'host' => 'required|ip|ipv4',
'user' => 'required',
'password' => 'nullable',
'status' => 'required'
];
}
}