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)); }
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; } }
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)); } }
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)); } }
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)); } }
public function images() { $images = \Storage::disk('uploads')->files($this->model); $images = array_map(function ($item) { $parts = explode('/', $item); return $parts[1]; }, $images); return $images; }
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); } }
public function moveToDisk($newDiskName) { if ($newDiskName == $this->disk) { return true; } $currentDisk = \Storage::disk($this->disk); $content = $currentDisk->get($this->path); $newDisk = \Storage::disk($newDiskName); $newDisk->put($this->path, $content); if ($newDisk->exists($this->path)) { $this->disk = $newDiskName; $this->save(); $currentDisk->delete($this->path); return true; } return false; }
/** * @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 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)); }
public function doPreview(ProductImportOptions $pio) { $data = []; $path = $pio->getUuid() . '/' . $pio->getFileName(); $fileContents = \Storage::disk('imports')->get($path); $csv = Reader::createFromString($fileContents); $csv->setDelimiter(','); if ($pio->isIncludeHeaders()) { $headers = $csv->fetchOne(); $data['headers'] = $headers; $csv->setOffset(1); } $previewRows = $csv->setLimit(25)->fetchAll(); $data['rows'] = $previewRows; return $data; }
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('opciones')->put($name, \File::get($imagen)); }