Add edit supplier products (phone)

This commit is contained in:
2025-05-18 21:14:02 +10:00
parent ac702397a6
commit 7fd1ce9584
9 changed files with 166 additions and 75 deletions

View File

@@ -73,6 +73,20 @@ class SupplierController extends Controller
->with('success','File uploaded');
}
public function product_new(SupplierProductAddEdit $request)
{
$o = Supplier::offeringTypeClass($request->validated('offering_type'));
foreach (Arr::except($request->validated(),['id','offering_type']) as $key => $value)
$o->{$key} = $value;
$o->save();
return redirect()
->back()
->with('success','Saved');
}
public function product_addedit(SupplierProductAddEdit $request,Supplier $o,int $id,string $type)
{
// Quick validation
@@ -88,7 +102,7 @@ class SupplierController extends Controller
// @todo these are broadband requirements - get them from the broadband class.
foreach (Arr::only($request->validated(),[
'supplier_detail_id',
'product_id'.
'product_id',
'product_desc',
'base_cost',
'setup_cost',
@@ -107,7 +121,7 @@ class SupplierController extends Controller
'extra_down_offpeak',
'extra_up_offpeak',
]) as $key => $value)
$oo->$key = $value;
$oo->{$key} = $value;
// Our boolean values
foreach (Arr::only($request->validated(),['active','extra_shaped','extra_charged']) as $key => $value)
@@ -115,6 +129,17 @@ class SupplierController extends Controller
break;
case 'phone':
$oo = Supplier\Phone::findOrNew($id);
foreach (Arr::except($oo->validation(),[
'id',
'offering_type',
]) as $key => $value)
$oo->{$key} = $request->validated($key);
break;
default:
throw new \Exception('Unknown offering type:'.$request->offering_type);
}