Updates to Product Model, product updates, enable pricing update, improved formating of product services

This commit is contained in:
2023-05-04 22:17:42 +10:00
parent 95bb55aad8
commit 0f91ce4940
21 changed files with 491 additions and 138 deletions

View File

@@ -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) {

View File

@@ -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
];
}
}