/**
  * @param \Exolnet\Image\Imageable $image
  * @return bool
  */
 public function destroy(Imageable $image)
 {
     if ($this->filesystem->exists($image->getImagePath())) {
         return $this->filesystem->delete($image->getImagePath());
     }
     return true;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     foreach ($this->files->files(storage_path() . '/views') as $file) {
         $this->files->delete($file);
     }
     $this->info('Views deleted from cache');
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->cache->flush();
     $this->files->delete($this->laravel['config']['app.manifest'] . '/services.json');
     $this->laravel['events']->fire('cache:cleared');
     $this->info('Application cache cleared!');
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach ($this->files->files(storage_path() . '/framework/sessions') as $file) {
         $this->files->delete($file);
     }
     $this->info('Session files deleted from storage');
 }
 /**
  * @param string $dir
  */
 protected function removeFiles($dir)
 {
     $files = $this->filesystem->glob($dir . '/*');
     foreach ($files as $file) {
         $this->filesystem->delete($file);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function gc($lifetime)
 {
     $files = Finder::create()->in($this->path)->files()->ignoreDotFiles(true)->date('<= now - ' . $lifetime . ' seconds');
     foreach ($files as $file) {
         $this->files->delete($file->getRealPath());
     }
 }
 public function save($item, $value, $environment, $group, $namespace = null)
 {
     $path = DIR_APPLICATION . '/config/generated_overrides';
     if (!$this->files->exists($path)) {
         $this->files->makeDirectory($path, 0777);
     } elseif (!$this->files->isDirectory($path)) {
         $this->files->delete($path);
         $this->files->makeDirectory($path, 0777);
     }
     if ($namespace) {
         $path = "{$path}/{$namespace}";
         if (!$this->files->exists($path)) {
             $this->files->makeDirectory($path, 0777);
         } elseif (!$this->files->isDirectory($path)) {
             $this->files->delete($path);
             $this->files->makeDirectory($path, 0777);
         }
     }
     $file = "{$path}/{$group}.php";
     $current = array();
     if ($this->files->exists($file)) {
         $current = $this->files->getRequire($file);
     }
     array_set($current, $item, $value);
     $renderer = new Renderer($current);
     return $this->files->put($file, $renderer->render()) !== false;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach ($this->files->files(storage_path() . '/logs') as $file) {
         $this->files->delete($file);
     }
     $this->info('Log files deleted from storage');
 }
Example #9
0
 /** @test */
 public function it_should_create_a_file()
 {
     if ($this->finder->isFile("{$this->mediaPath}google-map_smallThumb.png")) {
         $this->finder->delete("{$this->mediaPath}google-map_smallThumb.png");
     }
     $this->imagy->get("/google-map.png", 'smallThumb', true);
     $this->assertTrue($this->finder->isFile("{$this->testbenchPublicPath}google-map_smallThumb.png"));
 }
Example #10
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $views = $this->files->glob($this->laravel['config']['view.compiled'] . '/*');
     foreach ($views as $view) {
         $this->files->delete($view);
     }
     $this->info('Compiled views cleared!');
 }
Example #11
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $files = new Filesystem();
     $files->deleteDirectory(app_path('Http/Controllers/Auth'));
     $files->delete(base_path('database/migrations/2014_10_12_000000_create_users_table.php'));
     $files->delete(base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php'));
     $this->info('Original Auth removed! Enjoy your fresh start.');
 }
 /**
  * @param int $minutes
  *
  * @return \Illuminate\Support\Collection
  */
 public function deleteFilesOlderThanMinutes(int $minutes) : Collection
 {
     $timeInPast = Carbon::now()->subMinutes($minutes);
     return collect($this->filesystem->files($this->directory))->filter(function ($file) use($timeInPast) {
         return Carbon::createFromTimestamp(filemtime($file))->lt($timeInPast);
     })->each(function ($file) {
         $this->filesystem->delete($file);
     });
 }
 public function testSave()
 {
     $group = md5(uniqid());
     $item = 'test.item';
     $key = "{$group}.{$item}";
     $this->repository->save($key, $group);
     $this->assertEquals($group, $this->repository->get($key, false));
     $this->files->delete(DIR_APPLICATION . "/config/generated_overrides/{$group}.php");
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info("Starting to clear cache...");
     if ($this->files->exists($path = EloquentCacheCommand::getCachedEloquentPath())) {
         $this->files->delete($path);
         $this->info("Cache cleared.");
     } else {
         $this->comment("No cache to clear.");
     }
 }
 /**
  * Handle the command.
  *
  * @param GenerateEntryModel $command
  */
 public function handle(GenerateEntryModel $command)
 {
     $stream = $command->getStream();
     $data = $this->getTemplateData($stream);
     $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/entry.stub');
     $file = $this->getFilePath($stream);
     $this->files->makeDirectory(dirname($file), 0777, true, true);
     $this->files->delete($file);
     $this->files->put($file, $this->parser->parse($template, $data));
 }
Example #16
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $files = new Filesystem();
     $files->deleteDirectory(app_path('Http/Controllers/Auth'));
     $files->delete(base_path('database/migrations/2014_10_12_000000_create_users_table.php'));
     $files->delete(base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php'));
     $this->info('Auth removed! Enjoy your fresh start.');
 }
Example #17
0
 /**
  * @return void
  */
 public function fire()
 {
     $path = $this->laravel['config']['view.compiled'];
     if (!$path) {
         throw new RuntimeException('View path not found.');
     }
     foreach ($this->files->glob("{$path}/*") as $view) {
         $this->files->delete($view);
     }
     $this->info('Compiled views cleared!');
 }
Example #18
0
 public function tearDown()
 {
     $remove = array_reverse($this->to_remove);
     foreach ($remove as $path) {
         if ($this->files->isDirectory($path)) {
             $this->files->deleteDirectory($path);
         } else {
             $this->files->delete($path);
         }
     }
 }
Example #19
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     foreach ($this->getFiles() as $file) {
         $this->files->delete($file);
         $this->line('<info>Removed File:</info> ' . $file);
     }
     foreach ($this->getDirectories() as $directory) {
         $this->files->deleteDirectory($directory);
         $this->line('<comment>Removed Directory:</comment> ' . $directory);
     }
     foreach ($this->getStubs() as $stub => $path) {
         $this->files->put($path, $this->files->get(__DIR__ . '/stubs/fresh/' . $stub));
     }
     $this->info('Scaffolding Removed!');
 }
 /**
  * Handle the command.
  *
  * @param Filesystem  $files
  * @param Application $application
  * @return string
  */
 public function handle(Filesystem $files, Application $application)
 {
     $path = $application->getStoragePath('models/' . studly_case($this->stream->getNamespace()));
     $model = $path . '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()) . 'EntryModel.php';
     if ($files->exists($model)) {
         $files->delete($model);
     }
     if (!$this->stream->isTranslatable()) {
         return;
     }
     $model = $path . '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()) . 'EntryTranslationsModel.php';
     if ($files->exists($model)) {
         $files->delete($model);
     }
 }
 /**
  * Handle the command.
  *
  * @param Application $application
  */
 public function handle(Application $application, Filesystem $files)
 {
     if (!class_exists('TeamTNT\\TNTSearch\\TNTSearch')) {
         return;
     }
     if (!class_exists($this->stream->getEntryModelName())) {
         return;
     }
     $model = $this->stream->getEntryModel();
     $index = $application->getStoragePath('search/' . $model->searchableAs() . '.index');
     if ($this->stream->isSearchable() && file_exists($index)) {
         return;
     }
     if (!$this->stream->isSearchable() && file_exists($index)) {
         $files->delete($index);
         return;
     }
     if (!$this->stream->isSearchable()) {
         return;
     }
     try {
         app(EngineManager::class)->engine('tntsearch')->initIndex($model);
     } catch (\Exception $e) {
         // Kewl.
     }
 }
 /**
  * Decompress archive and delete non-used files.
  *
  * @return void
  */
 protected function decompress()
 {
     $directory = dirname($this->archivePath);
     $this->externalCommand("tar zxf {$this->archivePath}", $directory);
     $specifics = [file_build_path($directory, 'index.html'), file_build_path($directory, 'all_english.html'), $this->archivePath];
     $this->filesystem->delete(array_merge($this->filesystem->glob(file_build_path($directory, '*e.html')), $this->getOldFiles($directory), $specifics));
 }
 /**
  * Perform undo action
  *
  * @return void
  */
 protected function undo()
 {
     // Delete status
     $deleteCompleted = true;
     // Get files from the json undo file
     $files = json_decode($this->filesystem->get($this->undoFilePath), true);
     // For each file
     $this->info('Deleting files:');
     foreach ($files as $file) {
         // If this file can be deleted
         if ($this->filesystem->isWritable($file)) {
             // Delete it
             $this->filesystem->delete($file);
             $this->info("  Deleted: {$file}");
         } else {
             // Set status
             $deleteCompleted = false;
             // Show error
             $this->error('Could not delete: ' . $file);
         }
     }
     // if the delete prccess finished successfully
     if ($deleteCompleted) {
         // Delete undo file
         $this->filesystem->delete($this->undoFilePath);
     }
 }
Example #24
0
 /**
  * Remove an item from the cache.
  *
  * @param  string  $key
  * @return void
  */
 public function forget($key)
 {
     $file = $this->path($key);
     if ($this->files->exists($file)) {
         $this->files->delete($file);
     }
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $vendorDir = realpath($this->argument('dir'));
     $this->info("Cleaning dir: {$vendorDir}");
     $rules = Config::get('laravel-vendor-cleanup::rules');
     $filesystem = new Filesystem();
     foreach ($rules as $packageDir => $rule) {
         if (!file_exists($vendorDir . '/' . $packageDir)) {
             continue;
         }
         $patterns = explode(' ', $rule);
         foreach ($patterns as $pattern) {
             try {
                 $finder = new Finder();
                 $finder->name($pattern)->in($vendorDir . '/' . $packageDir);
                 // we can't directly iterate over $finder if it lists dirs we're deleting
                 $files = iterator_to_array($finder);
                 /** @var \SplFileInfo $file */
                 foreach ($files as $file) {
                     if ($file->isDir()) {
                         $filesystem->deleteDirectory($file);
                     } elseif ($file->isFile()) {
                         $filesystem->delete($file);
                     }
                 }
             } catch (\Exception $e) {
                 $this->error("Could not parse {$packageDir} ({$pattern}): " . $e->getMessage());
             }
         }
     }
 }
Example #26
0
 /**
  * Remove an item from the cache.
  *
  * @param  string  $key
  * @return bool
  */
 public function forget($key)
 {
     $file = $this->path($key, true);
     if (strpos($file, '*') !== false) {
         list($dir, $pattern) = explode('*', $file, 2);
         $pattern = str_replace(['\\*', '*'], '.+', preg_quote('*' . $pattern));
         if (DIRECTORY_SEPARATOR == '\\') {
             $pattern = str_replace('/', '\\\\', $pattern);
         }
         $Directory = new \RecursiveDirectoryIterator($dir);
         $Iterator = new \RecursiveIteratorIterator($Directory);
         $objects = new \RegexIterator($Iterator, '~^' . $pattern . '$~i');
         $check = true;
         foreach ($objects as $file => $object) {
             if (!$this->files->delete($file)) {
                 $check = false;
             }
         }
         return $check;
     } else {
         if ($this->files->exists($file)) {
             return $this->files->delete($file);
         }
     }
     return false;
 }
 /**
  * Clears installation progress.
  *
  * @return void
  */
 public function clearInstallProgress()
 {
     $files = [$this->config->get('oxygen.mod-marketplace.install.log'), $this->config->get('oxygen.mod-marketplace.install.progress')];
     foreach ($files as $file) {
         $this->files->delete($file);
     }
 }
 public function deleteFile($idProject, $idFile)
 {
     try {
         // $projectFile = $this->repository->skipPresenter()->with(['files'])->find($idFile);
         /*
          * Busco o File do project e acesso o files que está relacionando no Project buscando o file
          */
         $projectFile = $this->repository->skipPresenter()->find($idProject)->files()->find($idFile);
         //pega no nome do arquivo e extensão para deletar da pasta
         $nomeFile = $idFile . "." . $projectFile->extension;
         //deleta da pasta
         $this->filesystem->delete($nomeFile);
         //return response()->json(['error' => false,'message' => "ProjectFile {$idFile} deleted"]);
     } catch (ModelNotFoundException $ex) {
         return $this->notFound($idFile);
     }
     //deleta o file da tabela
     try {
         $this->repository->skipPresenter()->find($idProject)->files()->detach($idFile);
     } catch (ModelNotFoundException $e) {
         try {
             $this->repository->skipPresenter()->find($idProject)->files()->detach($idFile);
             return response()->json(['error' => false, 'message' => "ProjectFile {$idFile} deleted"]);
         } catch (ModelNotFoundException $e) {
             return response()->json(['error' => true, 'message' => "ProjectFile {$idFile} not found"]);
         }
     }
 }
Example #29
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $files = new Filesystem();
     $files->deleteDirectory(app_path('Services'));
     $files->delete(base_path('resources/views/app.blade.php'));
     $files->delete(base_path('resources/views/home.blade.php'));
     $files->deleteDirectory(app_path('Http/Controllers/Auth'));
     $files->deleteDirectory(base_path('resources/views/auth'));
     $files->deleteDirectory(base_path('resources/views/emails'));
     $files->delete(app_path('Http/Controllers/HomeController.php'));
     $files->deleteDirectory(base_path('public/css'));
     $files->deleteDirectory(base_path('public/fonts'));
     $files->put(base_path('resources/assets/less/app.less'), '' . PHP_EOL);
     $files->deleteDirectory(base_path('resources/assets/less/bootstrap'));
     $files->put(app_path('Http/routes.php'), $files->get(__DIR__ . '/stubs/fresh-routes.stub'));
     $this->info('Scaffolding removed! Enjoy your fresh start.');
 }
 /**
  * @param $id
  * @return int
  */
 public function delete($id)
 {
     $category = $this->find($id);
     $this->file->delete($category->main_image_path);
     $this->file->delete($category->icon_path);
     $this->file->delete($category->small_icon_path);
     return $this->category->delete($id);
 }