This commit is contained in:
Kevin Adametz 2021-02-10 10:56:40 +01:00
parent 32595ab5a1
commit 13fb2cfe98
70 changed files with 3614 additions and 401 deletions

View file

@ -65,6 +65,18 @@ class ProductController extends Controller
$rules = array(
'name' => 'required',
);
/*if(isset($data['number']) && $data['number'] != ""){
$rules['number'] = 'int';
}*/
if(isset($data['wp_number'])){
if($data['id'] !== "new"){
$model = Product::findOrFail($data['id']);
$rules['wp_number'] = 'unique:products,wp_number,'.$model->id;
}else{
$rules['wp_number'] = 'unique:products,wp_number';
}
}
$validator = Validator::make(Request::all(), $rules);
if($data['id'] === "new"){
@ -72,8 +84,12 @@ class ProductController extends Controller
}else{
$model = Product::findOrFail($data['id']);
}
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
$data = [
'product' => $model,
'country_for_prices' => $country_for_prices,
];
if ($validator->fails()) {