mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-01 20:17:35 -04:00 
			
		
		
		
	Add Delete/Update methods into VendorAPIController
This commit is contained in:
		
							parent
							
								
									d82d134465
								
							
						
					
					
						commit
						b013d118ab
					
				| @ -1,5 +1,6 @@ | ||||
| <?php namespace App\Http\Controllers; | ||||
| // vendor
 | ||||
| use App\Http\Requests\UpdateVendorRequest; | ||||
| use Utils; | ||||
| use Response; | ||||
| use Input; | ||||
| @ -83,4 +84,73 @@ class VendorApiController extends BaseAPIController | ||||
| 
 | ||||
|         return $this->itemResponse($vendor); | ||||
|     } | ||||
| 
 | ||||
|         /** | ||||
|          * @SWG\Put( | ||||
|          *   path="/vendors/{vendor_id}", | ||||
|          *   tags={"vendor"}, | ||||
|          *   summary="Update a vendor", | ||||
|          *   @SWG\Parameter( | ||||
|          *     in="body", | ||||
|          *     name="body", | ||||
|          *     @SWG\Schema(ref="#/definitions/Vendor") | ||||
|          *   ), | ||||
|          *   @SWG\Response( | ||||
|          *     response=200, | ||||
|          *     description="Update vendor", | ||||
|          *      @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor")) | ||||
|          *   ), | ||||
|          *   @SWG\Response( | ||||
|          *     response="default", | ||||
|          *     description="an ""unexpected"" error" | ||||
|          *   ) | ||||
|          * ) | ||||
|          */ | ||||
| 
 | ||||
|     public function update(UpdateVendorRequest $request, $publicId) | ||||
|     { | ||||
|         if ($request->action) { | ||||
|             return $this->handleAction($request); | ||||
|         } | ||||
| 
 | ||||
|         $data = $request->input(); | ||||
|         $data['public_id'] = $publicId; | ||||
|         $vendor = $this->vendorRepo->save($data, $request->entity()); | ||||
| 
 | ||||
|         $vendor->load(['vendor_contacts']); | ||||
| 
 | ||||
|         return $this->itemResponse($vendor); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|         /** | ||||
|          * @SWG\Delete( | ||||
|          *   path="/vendors/{vendor_id}", | ||||
|          *   tags={"vendor"}, | ||||
|          *   summary="Delete a vendor", | ||||
|          *   @SWG\Parameter( | ||||
|          *     in="body", | ||||
|          *     name="body", | ||||
|          *     @SWG\Schema(ref="#/definitions/Vendor") | ||||
|          *   ), | ||||
|          *   @SWG\Response( | ||||
|          *     response=200, | ||||
|          *     description="Delete vendor", | ||||
|          *      @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor")) | ||||
|          *   ), | ||||
|          *   @SWG\Response( | ||||
|          *     response="default", | ||||
|          *     description="an ""unexpected"" error" | ||||
|          *   ) | ||||
|          * ) | ||||
|          */ | ||||
| 
 | ||||
|     public function destroy(UpdateVendorRequest $request) | ||||
|     { | ||||
|         $vendor = $request->entity(); | ||||
| 
 | ||||
|         $this->vendorRepo->delete($vendor); | ||||
| 
 | ||||
|         return $this->itemResponse($vendor); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user