Refactor request validation to use model-specific prop synchronization and add migrations for categories and brands

This commit is contained in:
2026-06-24 11:02:35 -03:00
parent 8d840d94a0
commit e4139d48aa
12 changed files with 136 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Domains\Catalog\Requests;
use App\Domains\Catalog\Models\Brand;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
@@ -21,7 +22,7 @@ class StoreBrandRequest extends FormRequest
'tenant_codigo' => ['required', 'string', 'exists:tenants,codigo'],
'nombre' => ['required', 'string', 'max:255'],
'descripcion' => ['nullable', 'string'],
...PropRules::sync(),
...PropRules::sync(Brand::class),
];
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Domains\Catalog\Requests;
use App\Domains\Catalog\Models\Category;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
@@ -21,7 +22,7 @@ class StoreCategoryRequest extends FormRequest
'tenant_code' => ['required_with:categoria_id', 'string', 'exists:tenants,codigo'],
'categoria_id' => ['nullable', 'integer', 'exists:categorias,id'],
'nombre' => ['required', 'string', 'max:255'],
...PropRules::sync(),
...PropRules::sync(Category::class),
];
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Domains\Catalog\Requests;
use App\Domains\Catalog\Models\Product;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@@ -25,7 +26,7 @@ class StoreProductRequest extends FormRequest
'nombre' => ['required', 'string', 'max:255'],
'descripcion' => ['nullable', 'string'],
'precio' => ['required', 'numeric', 'min:0'],
...PropRules::sync(),
...PropRules::sync(Product::class),
];
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Domains\Catalog\Requests;
use App\Domains\Catalog\Models\Brand;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
@@ -21,7 +22,7 @@ class UpdateBrandRequest extends FormRequest
'tenant_codigo' => ['required', 'string', 'exists:tenants,codigo'],
'nombre' => ['required', 'string', 'max:255'],
'descripcion' => ['nullable', 'string'],
...PropRules::sync(),
...PropRules::sync(Brand::class),
];
}
}

View File

@@ -31,7 +31,7 @@ class UpdateCategoryRequest extends FormRequest
Rule::notIn([$category?->id]),
],
'nombre' => ['required', 'string', 'max:255'],
...PropRules::sync(),
...PropRules::sync(Category::class),
];
}
}

View File

@@ -34,7 +34,7 @@ class UpdateProductRequest extends FormRequest
'nombre' => ['required', 'string', 'max:255'],
'descripcion' => ['nullable', 'string'],
'precio' => ['required', 'numeric', 'min:0'],
...PropRules::sync(),
...PropRules::sync(Product::class),
];
}
}