1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

update upload mime checks

This commit is contained in:
David Bomba 2023-02-27 20:12:59 +11:00
parent 29fff76a7f
commit 6e983cb506
44 changed files with 406 additions and 172 deletions

View File

@ -29,8 +29,15 @@ class UploadBankIntegrationRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -29,8 +29,15 @@ class UploadBankTransactionRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -38,14 +38,15 @@ class StoreClientRequest extends Request
public function rules()
{
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
if (isset($this->number)) {

View File

@ -38,14 +38,15 @@ class UpdateClientRequest extends Request
{
/* Ensure we have a client name, and that all emails are unique*/
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000';

View File

@ -29,8 +29,15 @@ class UploadClientRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -29,8 +29,15 @@ class UploadCompanyRequest extends Request
{
$rules = [];
if ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -43,14 +43,15 @@ class StoreCreditRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;

View File

@ -42,14 +42,15 @@ class UpdateCreditRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
if ($this->number) {

View File

@ -29,8 +29,15 @@ class UploadCreditRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -29,8 +29,15 @@ class UploadExpenseRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -29,8 +29,15 @@ class UploadGroupSettingRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -37,24 +37,15 @@ class StoreInvoiceRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$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';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';

View File

@ -39,14 +39,15 @@ class UpdateInvoiceRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['id'] = new LockedInvoiceRule($this->invoice);

View File

@ -29,14 +29,22 @@ class UploadInvoiceRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
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';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;
}
public function prepareForValidation()
{
}
}

View File

@ -113,14 +113,15 @@ class StorePaymentRequest extends Request
];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -38,21 +38,21 @@ class UpdatePaymentRequest extends Request
$rules = [
'invoices' => ['array', new PaymentAppliedValidAmount, new ValidCreditsPresentRule($this->all())],
'invoices.*.invoice_id' => 'distinct',
'documents' => 'mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
];
if ($this->number) {
$rules['number'] = Rule::unique('payments')->where('company_id', auth()->user()->company()->id)->ignore($this->payment->id);
}
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -29,8 +29,15 @@ class UploadPaymentRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -28,14 +28,15 @@ class StoreProductRequest extends Request
public function rules()
{
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['cost'] = 'sometimes|numeric';

View File

@ -31,14 +31,15 @@ class UpdateProductRequest extends Request
public function rules()
{
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['cost'] = 'numeric';

View File

@ -28,9 +28,15 @@ class UploadProductRequest extends Request
public function rules()
{
$rules = [];
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
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->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -42,6 +42,17 @@ class StoreProjectRequest extends Request
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id);
}
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $this->globalRules($rules);
}

View File

@ -37,6 +37,17 @@ class UpdateProjectRequest extends Request
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id);
}
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $this->globalRules($rules);
}

View File

@ -29,8 +29,15 @@ class UploadProjectRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -47,6 +47,17 @@ class StorePurchaseOrderRequest extends Request
$rules['is_amount_discount'] = ['boolean'];
$rules['line_items'] = 'array';
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;
}

View File

@ -50,6 +50,17 @@ class UpdatePurchaseOrderRequest extends Request
$rules['discount'] = 'sometimes|numeric';
$rules['is_amount_discount'] = ['boolean'];
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;
}

View File

@ -29,8 +29,15 @@ class UploadPurchaseOrderRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -39,14 +39,15 @@ class StoreQuoteRequest extends Request
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['number'] = ['nullable', Rule::unique('quotes')->where('company_id', auth()->user()->company()->id)];

View File

@ -37,16 +37,18 @@ class UpdateQuoteRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
if ($this->number) {
$rules['number'] = Rule::unique('quotes')->where('company_id', auth()->user()->company()->id)->ignore($this->quote->id);
}

View File

@ -29,8 +29,15 @@ class UploadQuoteRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -48,6 +48,17 @@ class StoreRecurringExpenseRequest extends Request
$rules['tax_amount2'] = 'numeric';
$rules['tax_amount3'] = 'numeric';
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $this->globalRules($rules);
}

View File

@ -48,6 +48,17 @@ class UpdateRecurringExpenseRequest extends Request
$rules['tax_amount3'] = 'numeric';
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $this->globalRules($rules);
}

View File

@ -29,8 +29,15 @@ class UploadRecurringExpenseRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -38,14 +38,15 @@ class StoreRecurringInvoiceRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;

View File

@ -38,14 +38,15 @@ class UpdateRecurringInvoiceRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
if ($this->number) {

View File

@ -29,8 +29,15 @@ class UploadRecurringInvoiceRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -37,14 +37,15 @@ class StoreRecurringQuoteRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;

View File

@ -37,14 +37,15 @@ class UpdateRecurringQuoteRequest extends Request
{
$rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) {
$documents = count($this->input('documents'));
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
foreach (range(0, $documents) as $index) {
$rules['documents.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
} elseif ($this->input('documents')) {
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
if ($this->number) {

View File

@ -29,8 +29,15 @@ class UploadRecurringQuoteRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;

View File

@ -20,6 +20,7 @@ class Request extends FormRequest
use MakesHash;
use RuntimeFormRequest;
protected $file_validation = 'sometimes|file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
/**
* Get the validation rules that apply to the request.
*

View File

@ -59,6 +59,17 @@ class StoreTaskRequest extends Request
}
}];
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $this->globalRules($rules);
}

View File

@ -30,7 +30,6 @@ class UpdateTaskRequest extends Request
*/
public function authorize() : bool
{
nlog("oioi");
//prevent locked tasks from updating
if ($this->task->invoice_id && $this->task->company->invoice_task_lock) {
return false;
@ -67,6 +66,17 @@ class UpdateTaskRequest extends Request
}
}];
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $this->globalRules($rules);
}

View File

@ -47,6 +47,16 @@ class StoreVendorRequest extends Request
$rules['currency_id'] = 'bail|required|exists:currencies,id';
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;
}

View File

@ -44,6 +44,17 @@ class UpdateVendorRequest extends Request
$rules['contacts.*.email'] = 'nullable|distinct';
$rules['currency_id'] = 'bail|sometimes|exists:currencies,id';
if($this->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;
}

View File

@ -29,8 +29,15 @@ class UploadVendorRequest extends Request
{
$rules = [];
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->file('documents') && is_array($this->file('documents')))
$rules['documents.*'] = $this->file_validation;
elseif($this->file('documents'))
$rules['documents'] = $this->file_validation;
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
}
return $rules;