public function add(Request $request)
 {
     $name = Input::get('user_name');
     $id = Input::get('user_id');
     $text = Input::get('description');
     if ($request->hasFile('filefield')) {
         $file = $request->file('filefield');
         $entry = new Fileentry();
         $filename = time() . '.' . $file->getClientOriginalExtension();
         $extension = $file->getClientOriginalExtension();
         //			Image::make($file)->orientate()->save(public_path('recipe/'. $filename));
         Storage::disk('local')->put($file->getFileName() . '.' . $extension, File::get($file));
         $entry->mime = $file->getClientMimeType();
         $entry->original_filename = $file->getClientOriginalName();
         $entry->filename = $file->getFilename() . '.' . $extension;
     }
     $entry->user_name = $name;
     $entry->user_id = $id;
     $entry->description = $text;
     $entry->save();
     //		$file = Request::file('filefield');
     //		$extension = $file->getClientOriginalExtension();
     //		Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));
     //		$entry = new Fileentry();
     //		$entry->mime = $file->getClientMimeType();
     //		$entry->original_filename = $file->getClientOriginalName();
     //		$entry->filename = $file->getFilename().'.'.$extension;
     //		$entry->user_name = $name;
     //		$entry->user_id = $id;
     //		$entry->description = $text;
     //
     //		$entry->save();
     return redirect('/');
 }
Example #2
0
 public function addThumbnail($file)
 {
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->save();
     return $entry->id;
 }
Example #3
0
 public function show($id)
 {
     $user = User::find($id);
     $entry = Fileentry::orderBy('id', 'DESC')->where('user_id', '=', $id)->get();
     $posts = DB::table('fileentries')->where('user_id', '=', $id)->count();
     return view('users.index', array('user' => $user, 'entries' => $entry, 'posts' => $posts));
 }
 public function get($filename)
 {
     $entry = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $file = Storage::disk('local')->get($entry->filename);
     //dd(Response($file, 200)->header('Content-Type', $entry->mine));
     return Response($file, 200)->header('Content-Type', $entry->mine);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $provider = Providers::findOrFail($id);
     $entries = Fileentry::where('idProvider', '=', $id)->paginate(10);
     $entries->setPath($id);
     return view('providers.show', compact('provider', 'entries'));
 }
 public function delete($filename)
 {
     $entry = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $file = Storage::disk('local')->delete($entry->filename);
     if ($file) {
         Fileentry::where('filename', '=', $filename)->delete();
     }
     return redirect('fileentry')->with('status', 'Profile updated!');
 }
Example #7
0
 public function get($filename)
 {
     $entry = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $file = \Storage::disk('local')->get($entry->filename);
     return $file;
     // dd($file);
     // dd(get_class_methods(new Response($file, 200)));
     // return (new Response($file, 200))
     //          ->header('Content-Type', $entry->mime);
 }
Example #8
0
 public function borrar($filename)
 {
     $archivo = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $exists = Storage::disk('local')->exists($archivo->filename);
     if ($exists) {
         Storage::delete($archivo->filename);
         $archivo->delete();
         flash()->overlay('Ha sido borrado sactifactoriamente', 'El archivo ' . $archivo->filename);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validation //
     $validation = Validator::make($request->all(), ['userfile' => 'required|mimes:pdf|min:1|max:250']);
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $fileentry = new Fileentry();
     // upload the file //
     $file = $request->file('userfile');
     $destination_path = 'files/';
     $filename = str_random(6) . '_' . $file->getClientOriginalName();
     $file->move($destination_path, $filename);
     // save file data into database //
     $fileentry->file = $destination_path . $filename;
     $fileentry->save();
     //*****************
     //NEEDS RETURN/REDIRECT
 }
Example #10
0
 public function add($id, $pid)
 {
     $userdata = User::find($id);
     $postdata = Fileentry::find($pid);
     $user = $userdata['id'];
     $post = $postdata['id'];
     $data = array('user_id' => $user, 'file_id' => $post);
     $db = DB::table('favorite')->insert($data);
     return redirect('/#' . $post->id);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  \App\Fileentry $filename
  * @return Response
  */
 public function destroy($filename)
 {
     //$filename->delete();
     $entry = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $entry->delete();
     Storage::disk('local')->delete($entry->filename);
     $entries = Fileentry::all();
     return Redirect('superadmin/filemanager')->with('message', 'File deleted.')->with('entries', $entries);
     // show after destroy post
     //return view('posts.show', compact('post'));
 }
 public function postDataUploaded(Request $req)
 {
     // dd($req->all());
     // ->skip($offset)
     //    ->take($perpage)
     //    ->get();
     $page = 1;
     if ($req->get('page')) {
         $page = $req->get('page');
     }
     $rows = 10;
     if ($req->get('rows')) {
         $rows = $req->get('rows');
     }
     $entries = Fileentry::skip($page)->take($rows)->paginate();
     // dd($rows);
     // dd($entries->toArray());
     $result['total'] = $entries->toArray()['total'];
     $result['rows'] = $entries->toArray()['data'];
     return json_encode($result);
     # code...
 }
Example #13
0
 public function show($idp)
 {
     $entries = Fileentry::where('idProvider', '=', $idp)->get();
     return view('fileentries.show', compact('entries'));
 }
Example #14
0
 public function destroyPicture($picture_id, $brand_id)
 {
     $brand = Brand::findOrFail($brand_id);
     //then we get the picture
     $picture = Fileentry::findOrFail($picture_id);
     $fs = new FileStorageController();
     $fs->deleteImage($picture->path);
     // first we detach the file from the brand;
     $brand->pictures()->detach($picture_id);
     // then we delete the record in the database
     $picture->delete();
     return \Response::json(['error' => false, 'code' => 200, 'feedback' => 'Brand picture removed.'], 200);
 }
Example #15
0
 public function destroyPicture($picture_id, $article_id)
 {
     $article = Article::findOrFail($article_id);
     //then we get the picture
     $picture = Fileentry::findOrFail($picture_id);
     //deletes the relationship of the file that is being deleted.
     $article->pictures()->detach($picture_id);
     $fs = new FileStorageController();
     $fs->deleteImage($picture->path);
     // then we delete the record in the database
     $picture->delete();
     return \Response::json(['error' => false, 'code' => 200, 'feedback' => 'Brand picture removed.'], 200);
 }
Example #16
0
 public function destroy($file_id)
 {
     $file = Fileentry::findOrFail($file_id);
     $file->delete();
     return \Response::json(['error' => false, 'code' => 200, 'feedback' => 'Model has been deleted.'], 200);
 }
Example #17
0
 public function get($filename)
 {
     $entry = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $file = Storage::disk('avatar')->get($entry->filename);
     return (new Response($file, 200))->header('Content-Type', $entry->mime);
 }
Example #18
0
 public function getFiles()
 {
     $model_id = "note," . $this->id;
     return Fileentry::where('model_id', '=', $model_id)->orderBy('original_filename')->get();
 }
 public function composeProductsForm()
 {
     view()->composer('site.products.fields', function ($view) {
         $view->with('categories', \App\Models\Category::lists('name', 'id'))->with('tags', \App\Models\Tag::lists('name', 'id'))->with('files', \App\Fileentry::lists('original_filename', 'id'));
     });
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $entry = Fileentry::find($id);
     $file = Storage::disk('local')->get($entry->filename);
     return (new Response($file, 200))->header('Content-Type', $entry->mime);
 }
 public function upload(Request $request, Note $note)
 {
     Log::info('Uploading Files!');
     $file = $request->file;
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->model_id = "note," . $note->id;
     $entry->save();
     return ['success' => false, 'data' => 200];
 }
 public function upload(Request $request)
 {
     Log::info('Uploading Files!');
     $file = $request->file;
     $extension = $file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
     $entry = new Fileentry();
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $file->getFilename() . '.' . $extension;
     $entry->model_id = "0";
     //create thumb for images
     if (strpos($file->getClientMimeType(), "image/") !== false) {
         $image = new ImageResize($file);
         $image->resizeToHeight(150);
         $entry->thumb = $image->getImageAsString();
     }
     $entry->save();
     return ['success' => false, 'data' => 200];
 }
Example #23
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $provider = Providers::findOrFail($id);
     $entries = Fileentry::where('idProvider', '=', '1')->get();
     return view('providers.show', compact('provider', 'entries'));
 }