mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 08:37:33 -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'))  | ||||
|             $this->saveDocuments($request->file('documents'), $invoice); | ||||
| 
 | ||||
|         if ($request->has('file'))  | ||||
|             $this->saveDocuments($request->file('documents'), $invoice); | ||||
| 
 | ||||
|         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'; | ||||
|         } | ||||
| 
 | ||||
|         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'] = ['required', Rule::exists('clients')->where('company_id', auth()->user()->company()->id)];
 | ||||
| 
 | ||||
|  | ||||
| @ -82,8 +82,6 @@ class UpdateInvoiceRequest extends Request | ||||
|             unset($input['documents']); | ||||
|         } | ||||
| 
 | ||||
| nlog($input); | ||||
| 
 | ||||
|         $this->replace($input); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -33,6 +33,9 @@ class UploadInvoiceRequest extends Request | ||||
| 		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'; | ||||
| 
 | ||||
|         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; | ||||
| 
 | ||||
|     } | ||||
|  | ||||
| @ -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'])) { | ||||
|             foreach ($input['invitations'] as $key => $value) { | ||||
|                 if (isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) { | ||||
|  | ||||
| @ -222,6 +222,9 @@ class BaseRepository | ||||
|         if (array_key_exists('documents', $data))  | ||||
|             $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 (isset($data['invitations'])) { | ||||
|             $invitations = collect($data['invitations']); | ||||
|  | ||||
| @ -45,6 +45,7 @@ trait SavesDocuments | ||||
|                 $is_public | ||||
|             ); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function saveDocument($document, $entity, $is_public = true) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user