Refactor request validation to use model-specific prop synchronization and add migrations for categories and brands
This commit is contained in:
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class UpdateCategoryRequest extends FormRequest
|
||||
Rule::notIn([$category?->id]),
|
||||
],
|
||||
'nombre' => ['required', 'string', 'max:255'],
|
||||
...PropRules::sync(),
|
||||
...PropRules::sync(Category::class),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user