user(); return $user->can('edit', $this->invoice); } 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->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() { //tests to see if upload via binary data works. // if(request()->getContent()) // { // // $file = new UploadedFile(request()->getContent(), request()->header('filename')); // $file = new UploadedFile(request()->getContent(), 'something.png'); // // request()->files->set('documents', $file); // $this->files->add(['file' => $file]); // // Merge it in request also (As I found this is not needed in every case) // $this->merge(['file' => $file]); // } } }