/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $file = $request->file('file');
     $filename = $file->getFilename();
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($filename . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->original_mime_type = $file->getClientMimeType();
     $entry->original_extension = $file->getClientOriginalExtension();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->mime_type = $file->getMimeType();
     $entry->extesion = $file->guessExtension();
     $entry->save();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(ModelRequest $request)
 {
     try {
         $model = new Fileentry($request->all());
         if ($request->hasFile('file_upload')) {
             $file = $request->file('file_upload');
             if ($file->isValid()) {
                 $new_ext = $file->guessExtension();
                 $new_mime_tipe = $file->getMimeType();
                 if ($new_ext == 'bin') {
                     $new_ext = $file->getClientOriginalExtension();
                     $new_mime_tipe = $file->getClientMimeType();
                 }
                 $model->original_name = $file->getClientOriginalName();
                 $model->original_mime_type = $file->getClientMimeType();
                 $model->original_extension = $file->getClientOriginalExtension();
                 $model->name = $this->save_upload($file, $new_ext);
                 $model->mime_type = $new_mime_tipe;
                 $model->extension = $new_ext;
                 $model->size = $file->getSize();
                 $model->sha1 = sha1_file(base_path($model->name));
             }
         }
         try {
             DB::beginTransaction();
             $model->save();
             DB::commit();
             flash()->info("{$this->model_name} saved");
             return redirect(route($this->show_route, [$model->id]));
         } catch (Exception $e) {
             DB::rollBack();
             throw $e;
         }
     } catch (Exception $e) {
         $errors = [];
         flash()->error($e->getMessage());
         return $request->response($errors);
     }
 }