Updates to Product Model, product updates, enable pricing update, improved formating of product services
This commit is contained in:
@@ -97,6 +97,18 @@ class ProductController extends Controller
|
||||
|
||||
$o->active = (bool)$request->active;
|
||||
|
||||
// Trim down the pricing array, remove null values
|
||||
$o->pricing = $o->pricing->map(function($item) {
|
||||
foreach ($item as $k=>$v) {
|
||||
if (is_array($v)) {
|
||||
$v = array_filter($v);
|
||||
$item[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
try {
|
||||
$o->save();
|
||||
} catch (\Exception $e) {
|
||||
|
@@ -35,6 +35,7 @@ class ProductAddEdit extends FormRequest
|
||||
'model' => 'sometimes|string', // @todo Check that it is a valid model type
|
||||
'model_id' => 'sometimes|int', // @todo Check that it is a valid model type
|
||||
'accounting' => 'nullable|string',
|
||||
'pricing' => 'required|array', // @todo Validate the elements in the pricing
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user