| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function __invoke(Request $request) |
||
| 17 | { |
||
| 18 | $this->authorize('manage', Customer::class); |
||
| 19 | |||
| 20 | // Verify that the selected parent ID does not have a parent ID |
||
| 21 | $parent = Customer::findOrFail($request->parent_id); |
||
| 22 | if($parent->parent_id) |
||
| 23 | { |
||
| 24 | $request->parent_id = $parent->parent_id; |
||
| 25 | } |
||
| 26 | |||
| 27 | Customer::find($request->cust_id)->update([ |
||
| 28 | 'parent_id' => $request->parent_id, |
||
| 29 | ]); |
||
| 30 | Log::channel('cust')->info('Customer ID '.$request->cust_id.' has been linked to '.$request->parent_id.' by '.$request->user()->username); |
||
| 31 | |||
| 32 | return back()->with(['message' => 'Customer successfully linked', 'type' => 'success']); |
||
| 33 | } |
||
| 35 |