public function update($id, Request $request)
 {
     $file = $request->file('file');
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = Fileentry::find($id);
     $entry->original_mime_type = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->save();
 }
 public function getModels($filter = null)
 {
     $models = Fileentry::sortable($this->index_view);
     if ($this->show_trash()) {
         $models = $models->withTrashed();
     }
     if (isset($filter)) {
         foreach ($this->filter_fields as $field) {
             if (trim($filter[$field]) != '') {
                 $values = explode(',', $filter[$field]);
                 $first = true;
                 foreach ($values as $value) {
                     if ($field == 'id') {
                         if ($first) {
                             $models = $models->Where($field, $value);
                             $first = false;
                         } else {
                             $models = $models->orWhere($field, $value);
                         }
                     } else {
                         $value = '%' . $value . '%';
                         if ($first) {
                             $models = $models->Where($field, 'LIKE', $value);
                             $first = false;
                         } else {
                             $models = $models->orWhere($field, 'LIKE', $value);
                         }
                     }
                 }
             }
         }
     }
     return $models;
 }