예제 #1
0
 public function getImagen($id)
 {
     $ficha = Ficha::findOrFail($id);
     $mimetype = array('gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg');
     $content = NULL;
     $mime = NULL;
     foreach ($mimetype as $ext => $type) {
         if (Storage::has('fichas/' . $ficha->id . "." . $ext)) {
             $content = Storage::get('fichas/' . $ficha->id . "." . $ext);
             $mime = $type;
             break;
         }
     }
     if ($content == NULL) {
         abort(404);
     }
     return response($content)->header('Content-Type', $mime)->header('Content-Disposition', 'attachment')->header('filename', $ficha->numero . '.pdf');
 }
예제 #2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     User::saving(function ($user) {
         if ($user->password != '' && $user->remember_token == '') {
             $user->password = bcrypt($user->password);
         }
         //return $user;
     });
     Ficha::saved(function ($ficha) {
         if (Request::hasFile('archivo')) {
             $arch = Request::file('archivo');
             Storage::put('fichas/' . $ficha->id . '.pdf', File::get($arch));
         }
         if (Request::hasFile('imagen')) {
             $arch = Request::file('imagen');
             Storage::put('fichas/' . $ficha->id . '.' . $arch->getClientOriginalExtension(), File::get($arch));
             $data = File::get($arch);
         }
     });
 }
예제 #3
0
 public function postNuevo() {
     $ficha = \App\Ficha::crear(Input::all());
     if (!$ficha->hasErrors()) {
         Session::set('ficha', $ficha->toArray());
         return Redirect::to('fichas/modificar');
     } else {
         return Redirect::back()->withInput()->withErrors($ficha->getErrors());
     }
 }
예제 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  Ficha $ficha
  * @return \Illuminate\Http\Response
  */
 public function destroy(Ficha $ficha)
 {
     $ficha->delete();
     return redirect()->action('FichaController@index');
 }