mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 11:17:34 -04:00 
			
		
		
		
	Allow file key for uploads
This commit is contained in:
		
							parent
							
								
									7423be043d
								
							
						
					
					
						commit
						f2932c0354
					
				| @ -935,6 +935,9 @@ class InvoiceController extends BaseController | |||||||
|         if ($request->has('documents'))  |         if ($request->has('documents'))  | ||||||
|             $this->saveDocuments($request->file('documents'), $invoice); |             $this->saveDocuments($request->file('documents'), $invoice); | ||||||
| 
 | 
 | ||||||
|  |         if ($request->has('file'))  | ||||||
|  |             $this->saveDocuments($request->file('documents'), $invoice); | ||||||
|  | 
 | ||||||
|         return $this->itemResponse($invoice->fresh()); |         return $this->itemResponse($invoice->fresh()); | ||||||
| 
 | 
 | ||||||
|     }     |     }     | ||||||
|  | |||||||
| @ -47,6 +47,16 @@ class StoreInvoiceRequest extends Request | |||||||
|             $rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000'; |             $rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000'; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         if ($this->input('file') && is_array($this->input('file'))) { | ||||||
|  |             $documents = count($this->input('file')); | ||||||
|  | 
 | ||||||
|  |             foreach (range(0, $documents) as $index) { | ||||||
|  |                 $rules['file.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000'; | ||||||
|  |             } | ||||||
|  |         } elseif ($this->input('file')) { | ||||||
|  |             $rules['file'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000'; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         $rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; |         $rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; | ||||||
|         // $rules['client_id'] = ['required', Rule::exists('clients')->where('company_id', auth()->user()->company()->id)];
 |         // $rules['client_id'] = ['required', Rule::exists('clients')->where('company_id', auth()->user()->company()->id)];
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -82,8 +82,6 @@ class UpdateInvoiceRequest extends Request | |||||||
|             unset($input['documents']); |             unset($input['documents']); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| nlog($input); |  | ||||||
| 
 |  | ||||||
|         $this->replace($input); |         $this->replace($input); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -33,6 +33,9 @@ class UploadInvoiceRequest extends Request | |||||||
| 		if($this->input('documents')) | 		if($this->input('documents')) | ||||||
|             $rules['documents'] = 'file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000'; |             $rules['documents'] = 'file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000'; | ||||||
| 
 | 
 | ||||||
|  |         if($this->input('file')) | ||||||
|  |             $rules['file'] = 'file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000'; | ||||||
|  | 
 | ||||||
|     	return $rules; |     	return $rules; | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -123,17 +123,6 @@ class Request extends FormRequest | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(request()->has('file')) |  | ||||||
|         { |  | ||||||
| 
 |  | ||||||
|             request()->merge(['documents' => request()->file('file')]); |  | ||||||
| 
 |  | ||||||
|             // $requestFile = request()->files->get('file');
 |  | ||||||
| 
 |  | ||||||
|             // request()->files->add(['documents' => $requestFile]);
 |  | ||||||
| 
 |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (isset($input['invitations'])) { |         if (isset($input['invitations'])) { | ||||||
|             foreach ($input['invitations'] as $key => $value) { |             foreach ($input['invitations'] as $key => $value) { | ||||||
|                 if (isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) { |                 if (isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) { | ||||||
|  | |||||||
| @ -222,6 +222,9 @@ class BaseRepository | |||||||
|         if (array_key_exists('documents', $data))  |         if (array_key_exists('documents', $data))  | ||||||
|             $this->saveDocuments($data['documents'], $model); |             $this->saveDocuments($data['documents'], $model); | ||||||
| 
 | 
 | ||||||
|  |         if (array_key_exists('file', $data))  | ||||||
|  |             $this->saveDocuments($data['file'], $model); | ||||||
|  | 
 | ||||||
|         /* If invitations are present we need to filter existing invitations with the new ones */ |         /* If invitations are present we need to filter existing invitations with the new ones */ | ||||||
|         if (isset($data['invitations'])) { |         if (isset($data['invitations'])) { | ||||||
|             $invitations = collect($data['invitations']); |             $invitations = collect($data['invitations']); | ||||||
|  | |||||||
| @ -45,6 +45,7 @@ trait SavesDocuments | |||||||
|                 $is_public |                 $is_public | ||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function saveDocument($document, $entity, $is_public = true) |     public function saveDocument($document, $entity, $is_public = true) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user