public function setMntImgAttribute($file)
 {
     $name = $this->sanear_string(utf8_decode($this->MNT_NOMBRE));
     $this->attributes['MNT_IMG'] = 'image_' . str_replace(' ', '', $name) . '.jpg';
     $nombre = 'image_' . str_replace(' ', '', $name) . '.jpg';
     \Storage::disk('local')->put($nombre, \File::get($file));
 }
Example #2
0
 public function IdentitasHandle($req, $id)
 {
     // PDF tidak di update / melalui form
     // Gagal mengupload file PDF
     // Sukses Mengupload DOkumen
     $temp_iden_pesan = ['error' => ['user' => 'Peringatan : File PDF tidak di atur dengan benar !', 'sistem' => 'Terjadi kesalahan upload File PDf '], 'succes' => ['store' => 'Sukses mengupload Dokumen PDF ', 'update' => 'Sukses mengupdate Dokumen PDF ']];
     $temp_file_pesan = ['error' => '', 'succes' => ''];
     // dd($req->all());
     $file = $req->file('gambar');
     if ($file and $file->getClientMimeType() == 'application/pdf') {
         // dd($file);
         $extension = $file->getClientOriginalExtension();
         $FileIdentity = File::where('dokumen_id', $id);
         // Update
         if (count($FileIdentity->get()->toArray())) {
             $this->result['identitas']['lama'] = $FileIdentity->get()->toArray();
             //delete file
             $data_for_update = ['mime' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'filename' => $file->getFilename() . '.' . $extension];
             if ($FileIdentity->update($update)) {
                 $this->result['identitas']['baru'] = $FileIdentity->get()->toArray();
                 $this->{$result}['pesan'] = $temp_iden_pesan['succes']['update'];
                 // proses storage
                 if (\Storage::delete($FileIdentity->get()->toArray()[0]['filename']) && \Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
                     $this->file_pesan['succes'] = $temp_file_pesan['succes'];
                     return true;
                 } else {
                     $this->file_pesan['error'] = $temp_file_pesan['error'];
                     return false;
                 }
                 return true;
             } else {
                 return false;
             }
         } else {
             // echo " new file";
             $new_dokument = new File();
             $new_dokument->dokumen_id = $id;
             $new_dokument->mime = $file->getClientMimeType();
             $new_dokument->original_filename = $file->getClientOriginalName();
             $new_dokument->filename = $file->getFilename() . '.' . $extension;
             //new identitas
             if ($new_dokument->save()) {
                 // new pdf
                 if (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
                     return true;
                 }
                 $this->{$result}['pesan'] = $temp_iden_pesan['succes']['store'];
                 return true;
             } else {
                 $this->{$result}['pesan'] = $temp_iden_pesan['error']['sistem'];
                 return false;
             }
         }
         // }
     } else {
         $this->{$result}['pesan'] = $temp_iden_pesan['error']['user'];
         return false;
     }
 }
Example #3
0
 public function setPathAttribute($path)
 {
     if (!empty($path)) {
         $name = Carbon::now()->second . $path->getClientOriginalName();
         $this->attributes['path'] = $name;
         \Storage::disk('local')->put($name, \File::get($path));
     }
 }
Example #4
0
 public static function countries()
 {
     $countries = [];
     foreach (json_decode(\File::get(storage_path('app/countries.json')), true) as $country) {
         $countries[$country['code']] = $country['name'];
     }
     return $countries;
 }
Example #5
0
 public function setImgUrlAttribute($img_url)
 {
     if (!empty($img_url)) {
         $name = Carbon::now()->second . $img_url->getClientOriginalName();
         $this->attributes['img_url'] = $name;
         \Storage::disk('local')->put($name, \File::get($img_url));
     }
 }
Example #6
0
 public function setFotoAttribute($foto)
 {
     if (!empty($foto)) {
         $this->attributes['foto'] = Carbon::now()->second . $foto->getClientOriginalName();
         $name = Carbon::now()->second . $foto->getClientOriginalName();
         \Storage::disk('local')->put($name, \File::get($foto));
     }
 }
Example #7
0
 public function setImagenAttribute($imagen)
 {
     if (!empty($imagen)) {
         $this->attributes['imagen'] = \Carbon::now()->second . $imagen->getClientOriginalName();
         $filename = \Carbon::now()->second . $imagen->getClientOriginalName();
         \Storage::disk('local')->put($filename, \File::get($imagen));
         $thumb = \Image::make(\File::get($imagen));
         $ruta = public_path() . '/uploads/noticias/thumbs/';
         $thumb->resize(160, 100);
         $thumb->save($ruta . 'thumb_' . $filename);
     }
 }
Example #8
0
 /**
  * @param $img_url -> nombre del archivo que quiere subir
  *
  **/
 public function setImgUrlAttribute($img_url)
 {
     /*
      * protección al actualizar un record
      * si no se quiere actualizar la imagen, no se requiere subir una imagen y guardarla en la carpeta images
      *
      * si creamos un nuevo record,
      *  AdvertisemetRequest validará que se quiere subir una imagen para crear dicho record
      */
     if (!empty($img_url)) {
         /* concatena los segundos con el nombre del archivo que se subío para evitar overides */
         $name = Carbon::now()->second . $img_url->getClientOriginalName();
         /* renombra el archivo */
         $this->attributes['img_url'] = $name;
         /* almacena la imagen en nuestra caperta images */
         /* \Storage::disk('local') =  ruta de la carpeta images */
         \Storage::disk('local')->put($name, \File::get($img_url));
     }
 }
 public function setInfParrocoimgAttribute($file)
 {
     $this->attributes['INF_PARROCOIMG'] = 'image_parroco.jpg';
     $nombre = 'image_parroco.jpg';
     \Storage::disk('local')->put($nombre, \File::get($file));
 }
 public function setImagenAttribute($imagen)
 {
     $this->attributes['imagen'] = Carbon::now()->hour . Carbon::now()->minute . Carbon::now()->second . $imagen->getClientOriginalName();
     $name = Carbon::now()->hour . Carbon::now()->minute . Carbon::now()->second . $imagen->getClientOriginalName();
     Storage::disk('preguntas')->put($name, \File::get($imagen));
 }
Example #11
0
 public function SetMain_pictureAttribute($main_picture)
 {
     $this->attributes['main_picture'] = Carbon::now()->Second . $path->getClienteOriginalName();
     $name = Carbon::now()->Second . $path->getClienteOriginalName();
     \Storage::diSK('local')->put($name, \File::get($main_picture));
 }
 public function __construct()
 {
     $this->books = Book::get();
     $this->files = File::get();
 }
Example #13
0
 public function setNtImagenAttribute($file)
 {
     $this->attributes['NT_IMAGEN'] = 'image_' . str_replace(' ', '', date("YmdHis")) . '.jpg';
     $nombre = 'image_' . str_replace(' ', '', date("YmdHis")) . '.jpg';
     \Storage::disk('noticias')->put($nombre, \File::get($file));
 }
Example #14
0
 public function getFit($rawOptions)
 {
     $options = array_only($rawOptions, ['width', 'height']);
     if (empty($options)) {
         return $this->getFull();
     }
     $fitName = $this->hash . '-' . urlencode(\GuzzleHttp\Psr7\build_query($options)) . '.' . $this->extension;
     $fitPath = storage_path("images/fit/{$fitName}");
     if (\File::exists($fitPath)) {
         return \File::get($fitPath);
     }
     $img = ImageLib::make($this->getPath());
     $newWidth = array_get($options, 'width', null);
     $newHeight = array_get($options, 'height', null);
     if ($newWidth) {
         if ($newHeight) {
             // both width and height
             $img->fit($newWidth, $newHeight);
         } else {
             // Only Width
             $img->widen($newWidth);
         }
     } else {
         if ($newHeight) {
             // only height
             $img->heighten($newHeight);
         }
     }
     $img->save($fitPath);
     return \File::get($fitPath);
 }
Example #15
0
 /**
  * Copy the local file to Storage
  */
 protected function copyLocalToStorage($localPath, $storagePath)
 {
     return Storage::put($storagePath, FileHelper::get($localPath), $this->isPublic() ? 'public' : null);
 }