Exemplo n.º 1
0
 public static function upload(UploadedFile $file, $bucketName)
 {
     if (!$file->isValid()) {
         throw new \Exception(trans('validation.invalid_file'));
     }
     $bucket = Bucket::find($bucketName);
     if (!empty($bucket->mimeTypes()) && !in_array($file->getMimeType(), $bucket->mimeTypes())) {
         throw new \Exception(trans('validation.invalid_file_type'));
     }
     if (!empty($bucket->maxSize()) && !in_array($file->getClientSize(), $bucket->maxSize())) {
         throw new \Exception(trans('validation.invalid_file_size'));
     }
     $disk = Storage::disk($bucket->disk());
     $media = Media::create(['mime' => $file->getMimeType(), 'bucket' => $bucketName, 'ext' => $file->guessExtension()]);
     $disk->put($bucket->path() . '/original/' . $media->fileName, File::get($file));
     if (is_array($bucket->resize())) {
         foreach ($bucket->resize() as $name => $size) {
             $temp = tempnam(storage_path('tmp'), 'tmp');
             Image::make(File::get($file))->fit($size[0], $size[1])->save($temp);
             $disk->put($bucket->path() . '/' . $name . '/' . $media->fileName, File::get($temp));
             unlink($temp);
         }
     }
     return $media;
 }
 public function upload(ProductsImagesRequest $request, $id, Storage $storage)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $this->productsImagesRepository->create(['product_id' => $id, 'extension' => $extension]);
     $storage::disk('local_public')->put($image->id . '.' . $extension, File::get($file));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('campaign_manage')->truncate();
     DB::table('campaign_manage_country')->truncate();
     DB::table('campaign_manage_date')->truncate();
     DB::table('campaign_manage_time')->truncate();
     $campaigns = json_decode(File::get('database/migrations/jsondata/campaigns.json'));
     $default_parameters = array();
     $default_parameters['countries'] = 10000;
     $default_parameters['dates'] = 1000;
     $default_parameters['hours'] = 100;
     foreach ($campaigns as $campaign) {
         $campaign = CampaignManage::create(array('id' => '', 'campaign_id' => $campaign->id, 'platform_id' => 1));
         $relationships = array_intersect_key($default_parameters, array_flip(CampaignManage::$relationshipsAllowedToUpdate));
         if (!empty($relationships)) {
             foreach ($relationships as $relationshipType => $relationshipValue) {
                 if (!empty($relationshipValue)) {
                     if (!is_array($relationshipValue)) {
                         $relationshipValue = explode(',', $relationshipValue);
                     }
                     $campaign->{$relationshipType}()->sync($relationshipValue);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $file = Request::file('xmlfile');
     $type = Input::get('type');
     $userid = Input::get('userid');
     $alpha = Input::get('alpha');
     $extension = $file->getClientOriginalExtension();
     $oname = $file->getClientOriginalName();
     Storage::disk('local')->put("uploads/" . $file->getClientOriginalName(), File::get($file));
     $parser = new Parser();
     $contents = Storage::get("uploads/" . $file->getClientOriginalName());
     $rawxml = $parser->xml($contents);
     $importer = new Importer();
     if ($type == 'recipes') {
         $importer->parseRecipe($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'blocks') {
         $importer->parseBlocks($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'materials') {
         $importer->parseMaterial($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'items') {
         $importer->parseItems($rawxml, $userid, $alpha, 1);
     }
     //Flash::success('You successfully imported a '.$type.' xml file for 7 Days to Die Alpha '.$alpha.'!');
     return view('pages.import');
 }
Exemplo n.º 5
0
 /**
  * Handles upload image. Returns exception instance on error or file name on success.
  *
  * @param UploadedFile $uploadedFile
  * @param string $context
  * @param string $storage
  * @param null|string $fileName
  *
  * @return \Exception|string
  * @throws \Exception
  */
 public static function uploadImage(UploadedFile $uploadedFile, $context, $storage = 'local', $fileName = null)
 {
     $file = Facades\File::get($uploadedFile);
     /** @var Processor $processor */
     $processor = app('icr.processor');
     return $processor->upload($context, $file, $uploadedFile->getClientOriginalExtension(), Facades\Storage::disk($storage), $fileName);
 }
Exemplo n.º 6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach (config('uploader') as $bucket => $config) {
         if (isset($config['resize'])) {
             $disk = Storage::disk($config['disk']);
             $this->info('Processing ' . $bucket);
             foreach (Media::where('bucket', $bucket)->get() as $image) {
                 $srcFile = $config['path'] . '/original/' . $image->fileName;
                 $this->info('Source File ' . $srcFile);
                 try {
                     if (!$disk->has($srcFile)) {
                         throw new Exception('File not found on source directory');
                     }
                     foreach ($config['resize'] as $name => $size) {
                         $temp = tempnam(storage_path('tmp'), 'tmp');
                         $file = $disk->get($srcFile);
                         Image::make($file)->fit($size[0], $size[1])->save($temp);
                         $destName = $config['path'] . '/' . $name . '/' . $image->fileName;
                         $disk->put($destName, File::get($temp));
                         unlink($temp);
                         $this->info(str_pad($name, 10) . ' >> ' . $destName);
                     }
                 } catch (Exception $e) {
                     $this->error('Failed to process image. ERR:' . $e->getMessage());
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Open and parse the log.
  *
  * @access public
  * @return array
  */
 public function log()
 {
     $this->empty = true;
     $log = array();
     $log_levels = $this->getLevels();
     $today = Carbon::today()->format('Y-m-d');
     if ($this->date != $today) {
         $log_file = preg_grep('/.*~$/', glob($this->path . '/api-error-' . $this->sapi . '*-' . $this->date . '.log'), PREG_GREP_INVERT);
     } else {
         $log_file = preg_grep('/.*~$/', glob($this->path . '/api-error-' . $this->sapi . '*.log'), PREG_GREP_INVERT);
         $log_file = array_reverse($log_file);
     }
     if (!empty($log_file)) {
         $this->empty = false;
         $file = File::get($log_file[0]);
         $jsonObjects = $this->json_split_objects($file);
         if (!empty($jsonObjects)) {
             foreach ($jsonObjects as $jsonObj) {
                 $json = json_decode($jsonObj, true);
                 $level = !empty($json['@fields']['level']) ? static::$levels[$json['@fields']['level']] : 'None';
                 $header = "[{$json["@timestamp"]}] " . $level . " " . preg_split("/\\n/", $json['@message'])[0];
                 if (strcasecmp($this->level, $level) == 0 || $this->level == 'all') {
                     $log[] = array('level' => $log_levels[$level], 'header' => $header, 'stack' => $json['@message']);
                 }
             }
         }
     }
     if (strtolower(Config::get('logviewer::log_order')) == 'desc') {
         $log = array_reverse($log);
     }
     return $log;
 }
Exemplo n.º 8
0
 /**
  * Shows the player profile
  *
  * @param  integer $id
  * @param  string  $name
  */
 public function profile($id, $name = '')
 {
     // Cache key
     $key = sprintf('player.%u', $id);
     // Is there already a cached version for the player
     $isCached = Cache::has($key);
     // Get or Set cache for player
     $player = Cache::remember($key, 5, function () use($id) {
         $json = $this->repository->setopts(['ban.previous.server', 'ban.record.server', 'reputation', 'infractionsGlobal', 'infractionsServer.server', 'stats.server', 'specialGroups'], true)->getPlayerById($id)->toJson();
         return json_decode($json);
     });
     $charts = Cache::remember(sprintf('player.%u.charts', $id), 5, function () use($id) {
         $charts = [];
         $charts['overview'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandOverview.sql'), [$id]));
         $charts['spline'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandHistory.sql'), [$id]));
         $charts['aliases'] = Record::where('command_type', 48)->where('target_id', $id)->select(DB::raw('record_message AS `player_name`, COUNT(record_id) AS `seen`'))->groupBy('player_name')->get();
         $charts['iphistory'] = Record::where('command_type', 49)->where('target_id', $id)->where('record_message', '!=', 'No previous IP on record')->select(DB::raw('record_message AS `ip`, COUNT(record_id) AS `seen`'))->groupBy('ip')->get();
         $charts['overview'] = $charts['overview']->map(function ($command) {
             return [$command->label, intval($command->value)];
         });
         $charts['aliases'] = $charts['aliases']->map(function ($a) {
             return [$a->player_name, intval($a->seen)];
         });
         $charts['iphistory'] = $charts['iphistory']->map(function ($ip) {
             return [$ip->ip, intval($ip->seen)];
         });
         return $charts;
     });
     $groups = MainHelper::specialGroups($player->special_groups, 'player_group');
     $page_title = !empty($player->ClanTag) ? sprintf('[%s] %s', $player->ClanTag, $player->SoldierName) : $player->SoldierName;
     return View::make('player.profile', compact('player', 'page_title', 'charts', 'isCached', 'groups'));
 }
Exemplo n.º 9
0
 public function actualizar($id, Request $request)
 {
     try {
         $rules = array('nombre' => array('required', 'string', 'min:5', 'unique:promociones,nombre' . $id), 'descripcion' => array('required', 'string', 'min:30'), 'imagen' => array('image', 'image_size:>=300,>=300'), 'inicio' => array('date'), 'fin' => array('date', 'after: inicio'));
         $this->validate($request, $rules);
         $registro = Promociones::find($id);
         $registro->nombre = \Input::get('nombre');
         $registro->descripcion = \Input::get('descripcion');
         if ($archivo = BRequest::file('foto')) {
             $foto = BRequest::file('imagen');
             $extension = $foto->getClientOriginalExtension();
             Storage::disk('image')->put($foto->getFilename() . '.' . $extension, File::get($foto));
             $registro->imagen = $foto->getFilename() . '.' . $extension;
         }
         if ($inicio = \Input::get('inicio')) {
             $registro->inicio = \Input::get('inicio');
         }
         if ($inicio = \Input::get('fin')) {
             $registro->fin = \Input::get('fin');
         }
         $registro->save();
         return \Redirect::route('adminPromociones')->with('alerta', 'La promocion ha sido modificada con exito!');
     } catch (ValidationException $e) {
         return \Redirect::action('PromocionesCtrl@editar', array('id' => $id))->withInput()->withErrors($e->get_errors());
     }
 }
 public function saveImage($request, $id)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $this->model->create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('local_public')->put($image->id . '.' . $extension, File::get($file));
 }
Exemplo n.º 11
0
 public function updateFile($id, Request $request)
 {
     $file = $request->file('updateFile');
     $entry = FileRecord::where('id', '=', $id)->firstOrFail();
     Storage::disk('local')->put($entry->owner_id . $entry->id . $entry->filename . "/" . ($entry->total_versions + 1), File::get($file));
     $entry->total_versions = $entry->total_versions + 1;
     $entry->public_version = $entry->total_versions;
     $docVersions = (array) json_decode($entry->version_details);
     $version = $entry->total_versions - 1;
     $note = $request->updateDetails;
     $date = Carbon::now();
     $user = Auth::User()->fname . ' ' . Auth::User()->lname;
     $versionArray = [$version => array('user' => $user, 'stamp' => $date, 'note' => $note)];
     $finalVer = json_encode(array_merge($docVersions, $versionArray));
     $entry->version_details = $finalVer;
     $entry->save();
     $admins = User::get()->where('user_type_id', 1);
     foreach ($admins as $admin) {
         $uploader = Auth::user()->fname . " " . Auth::user()->lname . " (" . Auth::user()->username . ")";
         Mail::queue('mail.adminFileUpdate', ['uploader' => $uploader, 'fileName' => $entry->filename, 'id' => $entry->id, 'version' => $entry->public_version], function ($message) use(&$admin) {
             $message->to($admin->email, $admin->fname)->subject('New File Update');
         });
     }
     return redirect('/');
 }
Exemplo n.º 12
0
 public function savePost()
 {
     $post = ['title' => Input::get('title'), 'content' => Input::get('content'), 'picture' => Input::get('picture')];
     $rules = ['title' => 'required', 'content' => 'required'];
     $valid = Validator::make($post, $rules);
     if ($valid->passes()) {
         $post = new Post($post);
         $post->comment_count = 0;
         $post->read_more = strlen($post->content) > 120 ? substr($post->content, 0, 120) : $post->content;
         /*
         $destinationPath = 'uploads'; // upload path
         			//$extension = Input::file('image')->getClientOriginalExtension(); // getting image extension
         			$fileName = time(); // renameing image
         			Input::file('images')->make($destinationPath, $fileName); // uploading file to given path
         			$post->images = Input::get($fileName);
         
         
         			$pic = Input::file('picture');
                
                     $pic_name = time();
                     Image::make($pic)->save(public_path().'/images/300x'.$pic_name);
                     $post->images = '/images/'.'300x'.$pic_name;
         			$post->images = Input::get($pic_name);
         */
         $file = Request::file('picture');
         $extension = $file;
         Images::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
         $post->images = $file->time();
         $post->save();
         return Redirect::to('admin/dash-board')->with('success', 'Post is saved!');
     } else {
         return Redirect::back()->withErrors($valid)->withInput();
     }
 }
Exemplo n.º 13
0
 public function add()
 {
     $file = Request::file('file');
     if (Request::hasFile('file')) {
         $extension = $file->getClientOriginalExtension();
         Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
         $entry = new \App\File();
         $entry->mime = $file->getClientMimeType();
         $entry->original_filename = $file->getClientOriginalName();
         $entry->filename = $file->getFilename() . '.' . $extension;
         $entry->save();
         $part = new Part();
         $part->file_id = $entry->id;
         $part->name = Request::input('name');
         $part->sku = Request::input('sku');
         $part->make = Request::input('make');
         $part->year = Request::input('year');
         $part->condition = Request::input('condition');
         $part->description = Request::input('description');
         $part->price = Request::input('price');
         $part->imageurl = Request::input('imageurl');
         if (Request::has('price')) {
             $part->save();
         }
     }
     return redirect('/admin/part');
 }
Exemplo n.º 14
0
 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('/');
 }
Exemplo n.º 15
0
 public function saveImage($path, $filename, $file)
 {
     $image = File::get($file);
     $fullpath = $path . $filename;
     Storage::disk('local')->put($fullpath, $image);
     return $fullpath;
 }
Exemplo n.º 16
0
 public function show($id)
 {
     $vid = Video::findOrFail($id);
     $path = env('FILE_UPLOAD_PATH') . '/' . $vid->id . '~' . $vid->upload_filename;
     $file = File::get($path);
     return (new Response($file, 200))->header('Content-Type', File::mimeType($path));
 }
 public function uploadW9(Request $request, $link, $app_name, $aff_code)
 {
     $affiliate_row = Affiliate::where('external_link', '=', $link)->first();
     if ($affiliate_row == null) {
         return redirect('error');
     }
     //$user_infusionsoft = UserInfusionsoft::where('app_name','=', $app_name)->first();
     $user_infusionsoft = $affiliate_row->infusionsoft_user;
     $app_infusionsoft = new iSDK();
     if (!$app_infusionsoft->cfgCon($user_infusionsoft->app_name, $user_infusionsoft->app_apikey)) {
         return redirect('error');
     }
     $file = $request->file('w9file');
     if ($file) {
         $extension = $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         if (strtolower($extension) != 'pdf' || $mimeType != 'application/pdf') {
             return redirect(URL::to('aff/' . $link . '/' . $app_name . '/' . $aff_code))->with('error', 'You can upload pdf files only.');
         }
         Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
         $affiliate_row->w9_file_original_name = $file->getClientOriginalName();
         $affiliate_row->w9_file = $file->getFilename() . '.' . $extension;
         $affiliate_row->save();
         return redirect(URL::to('aff/' . $link . '/' . $app_name . '/' . $aff_code))->with('success', 'Congratulations! Your W9 is uploaded.');
     }
     return redirect(URL::to('aff/' . $link . '/' . $app_name . '/' . $aff_code))->with('error', 'No file is selected.');
 }
Exemplo n.º 18
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Check file exists
     if (!File::exists($this->argument('file'))) {
         $this->comment('No coverage file found, skipping.');
         return 0;
     }
     // Open serialised file
     $serialised = File::get($this->argument('file'));
     if (!Str::startsWith($serialised, '<?php')) {
         $coverage = unserialize($serialised);
         // Require PHP object in file
     } else {
         $coverage = (require $this->argument('file'));
     }
     // Check coverage percentage
     $total = $coverage->getReport()->getNumExecutableLines();
     $executed = $coverage->getReport()->getNumExecutedLines();
     $percentage = nf($executed / $total * 100, 2);
     // Compare percentage to threshold
     $threshold = $this->argument('threshold');
     if ($percentage >= $threshold) {
         $this->info("Code Coverage of {$percentage}% is higher than the minimum threshold required {$threshold}%!");
         return;
     }
     // Throw error
     $this->error("Code Coverage of {$percentage}% is below than the minimum threshold required {$threshold}%!");
     return 1;
 }
Exemplo n.º 19
0
 public function add(Request $request)
 {
     $this->validate($request, ['empleado' => 'required', 'filefield' => 'required']);
     $file = $request->file('filefield');
     $extension = $file->getClientOriginalExtension();
     if ($extension !== 'pdf') {
         return redirect()->back()->with('info', 'El archivo debe ser un pdf válido');
     }
     $user_id = $request->empleado;
     $user = User::where('id', $user_id)->first();
     $nombre = $user->username;
     $mes = $request->month;
     // Esto no funciona y no se porque
     // setlocale(LC_TIME,"es_ES.UTF-8");
     // $monthName = strftime('%B', mktime(0, 0, 0, $mes));
     // $monthName = strftime("m", mktime(0, 0, 0, $mes, 10));
     $year = $request->year;
     $descripcion = $mes . ' ' . $year . ' ' . strtoupper($nombre);
     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->mes = $mes;
     $entry->year = $year;
     $entry->user_id = $user_id;
     $entry->descripcion = $descripcion;
     $entry->save();
     return redirect('fileentry')->withInput();
 }
Exemplo n.º 20
0
 /**
  * Saves File.
  *
  * @param string $fileName File input name
  * @param string $location Storage location
  *
  * @return array
  */
 public static function saveFile($fileName, $directory = '', $fileTypes = [])
 {
     if (is_object($fileName)) {
         $file = $fileName;
         $originalName = $file->getClientOriginalName();
     } else {
         $file = Request::file($fileName);
         $originalName = false;
     }
     if (is_null($file)) {
         return false;
     }
     if (File::size($file) > Config::get('quarx.maxFileUploadSize', '')) {
         throw new Exception('This file is too large', 1);
     }
     if (substr($directory, 0, -1) != '/') {
         $directory .= '/';
     }
     $extension = $file->getClientOriginalExtension();
     $newFileName = md5(rand(1111, 9999) . time());
     // In case we don't want that file type
     if (!empty($fileTypes)) {
         if (!in_array($extension, $fileTypes)) {
             throw new Exception('Incorrect file type', 1);
         }
     }
     Storage::disk(Config::get('quarx.storage-location', 'local'))->put($directory . $newFileName . '.' . $extension, File::get($file));
     return ['original' => $originalName ?: $file->getFilename() . '.' . $extension, 'name' => $directory . $newFileName . '.' . $extension];
 }
Exemplo n.º 21
0
 /**
  * Checks if file exsits
  * @param  string $file filename without .md
  * @return data         The file himself
  */
 public function fileExists($file)
 {
     if (!File::exists($this->location . '/' . $file . '.md')) {
         return 'File does not exists';
     }
     return File::get($this->location . '/' . $file . '.md');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('campaign')->truncate();
     $campaigns = json_decode(File::get('database/migrations/jsondata/campaigns.json'));
     foreach ($campaigns as $campaign) {
         Campaign::create(array('id' => $campaign->id, 'name' => $campaign->name));
     }
 }
Exemplo n.º 23
0
 /** @test */
 public function it_adds_an_script_action_to_the_elixir_file()
 {
     $report = ElixirFile::addScript('script.js');
     $this->assertEquals($report, 'SUCCESS');
     $fileContent = File::get($this->exampleFile);
     $contentShouldExist = "mix.browserify('script.js');";
     $this->assertContains($contentShouldExist, $fileContent);
 }
Exemplo n.º 24
0
 /** @test */
 public function it_add_an_import_for_a_vue_component_in_the_assembler_file()
 {
     $report = VueAssembler::vue()->addComponent('example-component', './components/ExampleComponent.vue');
     $this->assertEquals($report, 'SUCCESS');
     $fileContent = File::get($this->exampleFile);
     $contentShouldExist = "Vue.component('example-component', Vue.extend(require('./components/ExampleComponent.vue')));";
     $this->assertContains($contentShouldExist, $fileContent);
 }
 public function storeImage(ProdutoImageRequest $request, $id, ProdutoImage $produtoImage)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $produtoImage::create(['produto_id' => $id, 'extension' => $extension]);
     Storage::disk('public_local')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('admin.produtos.images', ['id' => $id]);
 }
Exemplo n.º 26
0
 /**
  * @param array $data
  * @return array
  */
 public function create(array $data)
 {
     $return = parent::create($data);
     if (!isset($return['error'])) {
         Storage::put($return->id . '.' . $return->extension, File::get($data['file']));
     }
     return $return;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ProductImageRequest $request, $id)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $this->image->create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('local_public')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('admin.images.index', $id);
 }
Exemplo n.º 28
0
 /**
  * Reindex a model to Elasticsearch
  *
  * @param Model $model
  */
 protected function reindexModel(Model $model)
 {
     $mapping = $this->option('mapping') ? json_decode(File::get($this->option('mapping')), true) : null;
     $this->info('---> Reindexing ' . get_class($model));
     $model->reindex($this->option('relations'), $this->option('batch'), $mapping, function ($batch) {
         $this->info("* Batch {$batch}");
     });
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\ProductImageRequest $request, $id)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $this->productImagesModel->create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('public_local')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('images', ['id' => $id]);
 }
Exemplo n.º 30
-1
 public function resize($filename, $sizeString)
 {
     // We can read the output path from our configuration file.
     $outputDir = Config::get('assets.images.paths.output');
     // Create an output file path from the size and the filename.
     $outputFile = $outputDir . '/' . $sizeString . '_' . $filename;
     // If the resized file already exists we will just return it.
     if (File::isFile($outputFile)) {
         return File::get($outputFile);
     }
     // File doesn't exist yet, so we will resize the original.
     $inputDir = Config::get('assets.images.paths.input');
     $inputFile = $inputDir . '/' . $filename;
     // Get the width and the height of the chosen size from the Config file.
     $sizeArr = Config::get('assets.images.sizes.' . $sizeString);
     $width = $sizeArr['width'];
     $height = $sizeArr['height'];
     // We want to crop the image so we set the resize mode and size.
     $size = new \Imagine\Image\Box($width, $height);
     $mode = \Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND;
     // Create the output directory if it doesn't exist yet.
     if (!File::isDirectory($outputDir)) {
         File::makeDirectory($outputDir);
     }
     // Open the file, resize it and save it.
     $this->imagine->open($inputFile)->thumbnail($size, $mode)->save($outputFile, array('quality' => 90));
     // Return the resized file.
     return File::get($outputFile);
 }