/** * @param string $key * * @return mixed */ public function search($key) { $hash = $this->hash(trim($key)); $value = $this->storage->read($this->dataLength, $this->position($hash) + $this->dataLength); $value = trim($value); if ('' == $value) { return null; } return $value; }
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 savePhotos($params = []) { $remove_photos = (array) $params['remove_photos']; $photos = $params['photos']; $main_photo = (int) $params['main_photo']; $path = $this->photos_path . '/' . $this->id; $id = $this->id; $food_photos = (array) $this->photos; foreach ($remove_photos as $photo) { \Storage::delete($path . '/' . $food_photos[$photo]); unset($food_photos[$photo]); } if ($photos) { foreach ($photos as $key => $photo) { $file_name = md5(str_random(30)) . '.jpg'; \Storage::put($path . '/' . $file_name, file_get_contents($photo->getRealPath())); $food_photos[] = $file_name; } } $food_photos = array_values($food_photos); if ($food_photos) { if ($main_photo) { $this->main_photo = $food_photos[$main_photo]; } if (!$this->main_photo || array_search($this->main_photo, $food_photos) === FALSE) { $this->main_photo = $food_photos[0]; } } else { $this->main_photo = ''; } $this->photos = $food_photos; $this->save(); }
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 getFotoAttribute($value) { if ($value) { return 'data:image/' . explode('.', $value)[1] . ';base64,' . base64_encode(\Storage::get('products/' . $value)); } else { return null; } }
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 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 savePhoto($photo) { if ($photo) { \Storage::put('photos/categories/' . $this->id . '.jpg', file_get_contents($photo->getRealPath())); $this->photo = TRUE; $this->save(); } }
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 images() { $images = \Storage::disk('uploads')->files($this->model); $images = array_map(function ($item) { $parts = explode('/', $item); return $parts[1]; }, $images); return $images; }
public function adminChange(User $user, Storage $storage) { if ($storage->active == 0) { //the storage already banned $storage->update(['active' => 1]); if ($storage->status == 1) { $user->usage->freeup($storage->capacity); } Flash::success(trans('admin/messages.storageActivate')); } elseif ($storage->active == 1) { //the storage already activated $storage->update(['active' => 0]); if ($storage->status == 1) { $user->usage->freeDown($storage->capacity); } Flash::success(trans('admin/messages.storageBan')); } return redirect()->back(); }
/** * @param string $key * @param string $value * @param int $parent * * @return int */ private function store($key, $value, $parent = -1) { $address = $this->nextAddress++; $node = $this->make($key, $value, $parent); $this->storage->write($node, $address * $this->fullLength); if ($parent < 0) { $this->top = $address; } return $address; }
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 storagePath() { if (is_dir(storage_path($this->id))) { return storage_path($this->id); } else { \Storage::makeDirectory($this->id); if (is_dir(storage_path($this->id))) { return storage_path($this->id); } return '/'; } }
public function getLocalCachePath() { switch ($this->disk) { case \Storage::getDefaultDriver(): $path = config('filesystems.disks.local.root') . '/' . $this->path; break; default: throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); break; } return $path; }
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 saveImage($announcement) { $ext = Input::file('image')->getClientOriginalExtension(); Storage::put('images/' . $announcement->id . '/' . $announcement->id . '.' . $ext, file_get_contents($request->file('image')->getRealPath())); /* $file = array('image' => Input::file('image')); // setting up rules $rules = array('image' => 'required',); //mimes:jpeg,bmp,png and for max size max:10000 // doing the validation, passing post data, rules and the messages $validator = Validator::make($file, $rules); if ($validator->fails()) { // send back to the page with the input data and errors return Redirect::to('upload')->withInput()->withErrors($validator); } else { // checking file is valid. if (Input::file('image')->isValid()) { $destinationPath = 'uploads/'.$announcement->id; // upload path $extension = Input::file('image')->getClientOriginalExtension(); // getting image extension $fileName = $announcement->id.'.'.$extension; // renameing image Input::file('image')->move($destinationPath, $fileName); // uploading file to given path // sending back with message Session::flash('success', 'Upload successfully'); } else { // sending back with error message. Session::flash('error', 'uploaded file is not valid'); } }*/ }
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)); }
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; }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); // $router->model('user' , 'App\User'); $router->bind('user', function ($value) { return User::with('roles')->findOrFail($value); }); /** * created by dara on 6/9/2015 * add binding for admin wild card */ $router->bind('admin', function ($value) { return User::with('roles')->findOrFail($value); }); /** * Created by Emad Mirzaie on 09/09/2015. * province wild cart */ $router->model('province', 'App\\Province'); $router->model('city', 'App\\Province'); $router->model('university', 'App\\University'); $router->model('article', 'App\\Article'); $router->model('post', 'App\\Post'); $router->model('category', 'App\\Category'); $router->model('sub_category', 'App\\Category'); $router->model('skill', 'App\\Skill'); $router->model('profile', 'App\\User'); $router->model('comment', 'App\\Comment'); $router->model('poll', 'App\\Poll'); $router->model('questionnaire', 'App\\Questionnaire'); $router->model('coupon_user', 'App\\CouponUser'); $router->model('showcase', 'App\\Showcase'); $router->model('sticky', 'App\\Sticky'); /** * Created By Dara on 22/10/2015 */ // $router->bind('offer',function($value){ // return Offer::findOrFail($value); // }); $router->bind('service', function ($value) { return CouponGallery::findOrFail($value); }); $router->bind('coupon', function ($value) { return Coupon::findOrFail($value); }); $router->bind('group', function ($value) { return Group::findOrFail($value); }); $router->bind('problem', function ($value) { return Problem::findOrFail($value); }); $router->model('offer', 'App\\Offer'); $router->model('shop', 'App\\Shop'); $router->model('product', 'App\\Product'); $router->bind('event', function ($value) { return Event::findOrFail($value); }); $router->bind('settle', function ($value) { return Settle::findOrFail($value); }); $router->bind('report', function ($value) { return Report::findOrFail($value); }); $router->bind('corporation', function ($value) { return Corporation::findOrFail($value); }); /** * Created By Dara on 25/12/2015 */ $router->bind('announcement', function ($value) { return Announcement::findOrFail($value); }); $router->bind('storage', function ($value) { return Storage::findOrFail($value); }); $router->bind('role', function ($value) { return Role::findOrFail($value); }); }
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)); }