deleteDirectory() public static method

The directory itself may be optionally preserved.
public static deleteDirectory ( string $directory, boolean $preserve = false ) : boolean
$directory string
$preserve boolean
return boolean
 /**
  * Check if a directory exists, if so delete it
  * @param string $model
  */
 public static function deleteDirectory($model)
 {
     $path = public_path('assets/img/' . $model->getTable() . '/' . $model->id);
     if (\File::exists($path)) {
         \File::deleteDirectory(public_path($path));
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::drop('users');
     //delete everything inside the profile pictures directory
     $path = public_path() . '/content/profile_pictures/';
     File::deleteDirectory($path, true);
 }
Example #3
0
 public function setUp()
 {
     parent::setUp();
     if (File::isDirectory('packages')) {
         File::deleteDirectory('packages');
     }
 }
Example #4
0
 public function tearDown()
 {
     parent::tearDown();
     $this->userFileStorage = null;
     File::deleteDirectory($this->tmpDir);
     File::cleanDirectory($this->storageDir);
 }
Example #5
0
 public function fire()
 {
     $options = $this->option();
     $this->seed_path = storage_path('seeder');
     Asset::setFromSeed(true);
     // -------------------------------------
     if (is_true($options['reset'])) {
         if (Config::getEnvironment() == 'production') {
             $really = $this->confirm('This is the *** PRODUCTION *** server are you sure!? [yes|no]');
             if (!$really) {
                 $this->info("**** Exiting ****");
                 exit;
             }
         }
         if (!File::exists($this->seed_path)) {
             File::makeDirectory($this->seed_path);
             $n = 50;
             for ($i = 1; $i <= $n; $i++) {
                 $gender_types = ['men', 'women'];
                 foreach ($gender_types as $gender) {
                     $user_photo_url = "http://api.randomuser.me/portraits/{$gender}/{$i}.jpg";
                     File::put($this->seed_path . "/{$gender}_{$i}.jpg", file_get_contents($user_photo_url));
                 }
                 $this->info("Cache user seed image - {$i}");
             }
         }
         if ($this->confirm('Do you really want to delete the tables? [yes|no]')) {
             // first delete all assets
             if (Schema::hasTable('assets')) {
                 foreach (Asset::all() as $asset) {
                     $asset->delete();
                 }
             }
             $name = $this->call('migrate');
             $name = $this->call('migrate:reset');
             File::deleteDirectory(public_path('assets/content/users'));
             $this->info('--- Halp has been reset ---');
         }
         Auth::logout();
         $this->setupDatabases();
         return;
     }
     // -------------------------------------
     if (is_true($options['setup'])) {
         $this->setupDatabases();
     }
     // -------------------------------------
     if ($options['seed'] == 'all') {
         $this->seed();
     }
     if ($options['seed'] == 'users') {
         $this->seedUsers();
     }
     if ($options['seed'] == 'tasks') {
         $this->seedTasks();
     }
     if ($options['seed'] == 'projects') {
         $this->seedProjects();
     }
 }
 public function testDirectoryCreation()
 {
     \File::deleteDirectory(storage_path(Jboysen\LaravelGcc\GCCompiler::STORAGE));
     $this->assertFalse(file_exists(storage_path(Jboysen\LaravelGcc\GCCompiler::STORAGE)));
     $this->createApplication();
     $this->assertTrue(file_exists(storage_path(Jboysen\LaravelGcc\GCCompiler::STORAGE)));
 }
Example #7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //borrramos generaciones previas
     File::deleteDirectory(app_path('modelos_generados'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('modelos_generados'), 777);
     $tablas = SchemaHelper\Table::getTablesCurrentDatabase();
     $this->info("Buscando tablas..");
     foreach ($tablas as $tabla) {
         $this->info("Generando Modelo de la tabla: " . $tabla->table_name);
         //class name
         $class_name = ucfirst(camel_case(str_singular_spanish($tabla->table_name)));
         $baseString = File::get(app_path('models/Schema/Template.txt'));
         //replace class name..
         $baseString = str_replace('@class_name@', $class_name, $baseString);
         //replace table name..
         $baseString = str_replace('@table_name@', $tabla->table_name, $baseString);
         //replace pretty name..
         $baseString = str_replace('@pretty_name@', $tabla->table_name, $baseString);
         //find columns.
         $columns = $tabla->columns()->whereNotIn('column_name', static::$common_hidden)->get();
         //generate fillable
         $baseString = str_replace('@fillable@', $this->generarFillable($columns), $baseString);
         //generate pretty fields string.
         $baseString = str_replace('@pretty_fields@', $this->generarPrettyFields($columns), $baseString);
         //generate rules..
         $baseString = str_replace('@rules@', $this->genenarRules($columns), $baseString);
         //generate belongs to..
         $baseString = str_replace('@belongs_to@', $this->generarBelongsTo($columns), $baseString);
         File::put(app_path('modelos_generados/' . $class_name . '.php'), $baseString);
     }
     $this->info("Generación terminada.");
 }
Example #8
0
 /**
  * Download the module from an url
  *
  * @param $url
  * @param $dest
  * @return bool
  */
 public static function download($url, $name, $dest = null)
 {
     if ($dest == null) {
         $dest = \Module::getPath();
     }
     $tmpName = date($name . '-Ymdhis.zip');
     $result = file_put_contents(__DIR__ . "/" . $tmpName, fopen($url, 'r'));
     if ($result) {
         $zip = new ZipArchive();
         if ($zip->open(__DIR__ . "/" . $tmpName) === true) {
             $destFolder = $dest . '/' . $name;
             $oldFolder = "";
             if (is_dir($destFolder)) {
                 $oldFolder = $destFolder . '-old';
                 if (is_dir($oldFolder)) {
                     \File::deleteDirectory($oldFolder);
                 }
                 rename($destFolder, $oldFolder);
             }
             $tmpFolder = $dest . '/' . $name . '-tmp';
             $zip->extractTo($tmpFolder);
             $zip->close();
             $file = glob($tmpFolder . '/*');
             $result = rename($file[0], $destFolder);
             \File::deleteDirectory($tmpFolder);
             if ($result) {
                 \File::deleteDirectory($oldFolder);
             }
             return $result;
         } else {
             return false;
         }
     }
     return false;
 }
 protected function upload()
 {
     $validator = $this->fileValidator(Input::all());
     if ($validator->passes()) {
         if ($this->_user->download_count) {
             \Excel::selectSheetsByIndex(0)->load(Input::get('file'), function ($reader) {
                 $finalHtml = '';
                 $currentTime = date('d-m-Y_His');
                 mkdir($currentTime);
                 foreach ($reader->toArray() as $row) {
                     $html = "\n\t\t\t<style>\n\t\t\t\t.page-break {\n\t    \t\t\tpage-break-after: always;\n\t\t\t\t}\n\t\t\t\t.outer-container {\n\t\t\t\t\tmargin: 0% auto;\n\t\t\t\t\tborder: 1px solid black;\n\t\t\t\t\ttext-align: center;\n\t\t\t\t\theight: 99%;\n\t\t\t\t}\n\t\t\t\t.subject-container {\n\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\tmargin-top: 30px;\n\t\t\t\t}\n\t\t\t\t.content-container {\n\t\t\t\t\ttext-align: left;\n\t\t\t\t\tpadding: 10px;\n\t\t\t\t\tmargin-top: 50px;\n\t\t\t\t}\n\t\t\t\tol {\n\t\t\t\t\ttext-align: left;\n\t\t\t\t}\n\t\t\t\tol li{\n\t\t\t\t\tpadding-bottom: 40px;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<div class='outer-container'>\n\t\t\t\t\n\t\t\t \t\t<p class='subject-container'>Subject: NOTICE UNDER SECTION 138 OF NEGOTIABLE INSTRUMENT ACT READ WITH SECTION 420 OF INDIAN PENAL CODE</p>\n\n\t\t\t\t\t<p class='content-container'>\n\t\t\t\t\t\tOn behalf of and under instructions of my client <u>{$row['name']}</u> S/o__________ R/o __________ (hereinafter referred to as &quot;my client&quot;). I do hereby serve you with the following legal notice:\n\n\t\t\t\t\t\t<ol>\n\t\t\t\t\t\t\t<li>That my client, an engineering student, while looking for job paid Rs {$row['amount']} to you for assured placement in an MNC, last year.</li>\n\t\t\t\t\t\t\t<li>That thereafter my client issued a number of reminders to you for placement, but still no opportunity was provided to him, i.e. as you were unable to fulfill the promise as to placement of my client. Therefore, it was decided between you and my client that the amount of Rs {$row['amount']} should be refunded and as a result you issued him a cheque no {$row['cheque_number']} dated {$row['cheque_date']}.</li>\n\t\t\t\t\t\t\t<li>That the said cheque was presented by my client to State Bank of India, Noida for credit in his account in the month of December 2011 itself, but it bounced due to insufficient funds. And my client contacted you and was assured of cash in lieu of bounced cheque, therefore, my client did not take legal action earlier. My client thereafter again requested many a time to you for the payment of the said cheque amount by telephone and/or through personal visit of his representative, but in vain.</li>\n\t\t\t\t\t\t\t<li>That in April 2012, my client again tried depositing the cheque with State Bank of India, Mysore but it was again returned as unpaid with remarks &#45; Funds Insufficient, vide Syndicate Bank memo dated 19 April 2012.</li>\n\t\t\t\t\t\t\t<li>That in the facts and circumstances created by you my above said client left with no alternative except to serve you the present notice and calling upon all of you to make the payment of the above mentioned cheque amount totaling Rs {$row['amount']}/- (Rupees Ten Thousand only) including bouncing charges in cash with interest @ 24% per annum within 15 days of the receipt of this notice failing which my client shall be constrained to institute against you a criminal complaint under section 138 of the Negotiable Instrument Act read with section 420 of IPC where under you could be sentenced to undergo imprisonment of the two years and also pay the fine equivalent of the double amount of the above mentioned cheque as well as legal charges of this notice of Rs 2100/-</li>\n\t\t\t\t\t\t\t<li>That a copy of this notice retained in my office for further reference /record and legal action.</li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t</p>\n\t\t\t</div>";
                     $finalHtml .= $html . "<div class='page-break'></div>";
                     \PDF::loadHTML($html)->setPaper('a4')->setOrientation('portrait')->setWarnings(false)->save($currentTime . '/' . $row["name"] . '_' . $row['cheque_number'] . '.pdf');
                 }
                 \PDF::loadHTML($finalHtml)->setPaper('a4')->setOrientation('portrait')->setWarnings(false)->save($currentTime . '/' . $currentTime . '.pdf');
                 // Here we choose the folder which will be used.
                 $dirName = public_path() . '/' . $currentTime;
                 // Choose a name for the archive.
                 $zipFileName = $this->_user->email . '_' . $currentTime . '.zip';
                 // Create ".zip" file in public directory of project.
                 $zip = new ZipArchive();
                 if ($zip->open(public_path() . '/' . $zipFileName, ZipArchive::CREATE) === TRUE) {
                     // Copy all the files from the folder and place them in the archive.
                     foreach (glob($dirName . '/*') as $fileName) {
                         $file = basename($fileName);
                         $zip->addFile($fileName, $file);
                     }
                     $zip->close();
                     $headers = array('Content-Type' => 'application/octet-stream');
                 } else {
                     echo 'failed';
                 }
                 $filename = $this->_user->email . '_' . $currentTime . '.zip';
                 $filepath = $_SERVER["DOCUMENT_ROOT"];
                 ob_start();
                 // http headers for zip downloads
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Cache-Control: public");
                 header("Content-Description: File Transfer");
                 header("Content-type: application/octet-stream");
                 header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
                 header("Content-Transfer-Encoding: binary");
                 header("Content-Length: " . filesize($filepath . "/" . $filename));
                 @readfile($filepath . "/" . $filename);
                 ob_end_flush();
                 \File::deleteDirectory($currentTime);
                 \File::delete($this->_user->email . '_' . $currentTime . '.zip');
                 // reader methods
                 $this->_user->download_count = $this->_user->download_count - 1;
                 $this->_user->save();
             });
         } else {
             return Redirect::to("home")->with('message', 'Your maximum download limit 3, exceeded in beta version.  Please subscribe to use this feature.');
         }
     }
     return Redirect::to("home")->withErrors($validator->messages());
 }
Example #10
0
 public function setUp()
 {
     parent::setUp();
     if (File::exists($this->tempDirectory)) {
         File::deleteDirectory($this->tempDirectory);
     }
     File::makeDirectory($this->tempDirectory);
 }
Example #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  PhotosRequest  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(PhotosRequest $request, $id)
 {
     //
     $imageDir = storage_path('app') . '/img/photos/' . $id;
     \File::cleanDirectory($imageDir);
     \File::deleteDirectory($imageDir);
     Photos::find($id)->delete();
     return \Redirect::back()->with('message', 'Fotoğraf Silindi!');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  GalleryCategory $category
  * @return Response
  */
 public function destroy(GalleryCategory $category)
 {
     \File::deleteDirectory(config('gallery.gallery_path') . '/' . $category->id . '/');
     $category->delete();
     if (\Request::ajax()) {
         return '';
     }
     return redirect()->route('admin.gallery.index');
 }
Example #13
0
 private function cleanup($requestId)
 {
     $dirs = \File::directories(self::DIR);
     foreach ($dirs as $dir) {
         if (strpos($dir, $requestId) !== false) {
             continue;
         }
         \File::deleteDirectory($dir);
     }
 }
Example #14
0
 public function remove($id)
 {
     $upload = Upload::findOrFail($id);
     if (!$upload->canDelete()) {
         return $this->_access_denied();
     }
     File::deleteDirectory($upload->path);
     $upload->delete();
     return Redirect::back()->with('notification:success', $this->deleted_message);
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     require __DIR__ . '/routes.php';
     $this->loadViewsFrom(__DIR__ . '/views', 'blog');
     $this->publishes([__DIR__ . '/config/blog.php' => config_path('blog.php'), __DIR__ . '/views' => base_path('resources/views/vendor/blog'), __DIR__ . '/database/migrations' => database_path('/migrations')]);
     if (glob(__DIR__ . '/model/publish/*.php')) {
         $this->publishes([__DIR__ . '/model/publish' => app_path('/')]);
         \File::deleteDirectory(__DIR__ . '/model/publish/', true);
     }
 }
Example #16
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $now = time();
     foreach (File::directories('public/uploads') as $dir) {
         $dirtime = filemtime($dir);
         if ($now - $dirtime > 3600) {
             File::deleteDirectory($dir);
             $this->info('Directory ' . $dir . ' was deleted');
         }
     }
 }
 public function fire()
 {
     if (!$this->option('verbose')) {
         $this->output = new NullOutput();
     }
     if (\File::isDirectory($indexPath = Config::get('laravel-lucene-search.index.path'))) {
         \File::deleteDirectory($indexPath);
         $this->info('Search index is cleared.');
     } else {
         $this->comment('There is nothing to clear..');
     }
 }
Example #18
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     if ($this->how == 'single') {
         $imageDir = storage_path('app') . '/img/photos/' . $this->model->id;
         \File::cleanDirectory($imageDir);
         \File::deleteDirectory($imageDir);
     } else {
         foreach ($this->model->photos as $photo) {
             $imageDir = storage_path('app') . '/img/photos/' . $photo->id;
             \File::cleanDirectory($imageDir);
             \File::deleteDirectory($imageDir);
             $photo->delete();
         }
     }
 }
Example #19
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Start with some information about what we are going to do here
     $this->line('This command will attempt to clear all of the cache services in use with SeAT.');
     $this->line('This only time that that this command should really be used is to aid developers in debugging.');
     $this->line('');
     $this->line('Ensure that the user invoking this command is allowed to access the cache directory.');
     // Be annoying and ask if the user is sure he wants to clear all caches
     if ($this->confirm('Are you sure you want to clear ALL caches (file/db/redis)? [yes|no]', true)) {
         $this->line('Clearing caches...');
         // Attempt cleanup of the pheal-ng disk cache.
         $success = \File::deleteDirectory(storage_path() . '/cache/phealcache', true);
         // If we failed to delete the contents of the cache directort,
         // let the user know how to delete this manually.
         if (!$success) {
             $this->error('Warning: Failed to delete pheal-ng disk cache! It may mean that the current user does not have the required permissions.');
             $this->error('You may manually attempt cleanup of this by deleting the contents of ' . storage_path() . '/cache/phealcache/');
         } else {
             $this->info('Pheal-ng disk cache cleared.');
             // As we have just wiped the contents, we have to put back the .gitignore.
             // Maybe there is a better way to do this, I don't know ^_^
             $gitignore_contents = "*\n!.gitignore";
             $file_write = \File::put(storage_path() . '/cache/phealcache/.gitignore', $gitignore_contents);
             // Check if this was successfull
             if ($file_write === false) {
                 $this->error('Warning: Failed to replace the .gitignore in ' . storage_path() . '/cache/phealcache/.gitignore. You should try this manually.');
             }
         }
         // Attempt to clear the Redis Cache
         try {
             $redis = new \Predis\Client(array('host' => \Config::get('database.redis.default.host'), 'port' => \Config::get('database.redis.default.port')));
             $redis->flushall();
             $this->info('Redis cache cleared.');
         } catch (\Exception $e) {
             $this->error('Warning: Failed to clear the Redis Cache. The error was: ' . $e->getMessage());
         }
         // Lastly, clean up the cached_until timers from the database
         // table.
         try {
             \DB::table('cached_until')->truncate();
             $this->info('DB cache cleared.');
         } catch (\Exception $e) {
             $this->error('Warning: Failed to clear the database cached_until table. The error was: ' . $e->getMessage());
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $canceled = true;
     $this->line('');
     $this->info("Preparing to delete Gravatar's configuration file .......");
     $this->line('');
     if ($this->confirm('Do you really want to delete Gravatar\'s configuration file ? [yes|no]')) {
         $this->info('Ok ... as you wish');
         $this->line('');
         \File::deleteDirectory(app_path() . '/config/packages/tournasdim');
         $canceled = false;
         $this->line('');
         $this->info('Now run a \'composer update\' to complete the process');
     }
     $this->line('');
     if ($canceled) {
         $this->info('You have canceled the process');
     }
 }
Example #21
0
 public function backup($tempDir, $targetDir)
 {
     $service = App::make('Tee\\Backup\\Services\\BackupService');
     $fileBackup = new \Tee\Backup\Package\Directory();
     if (!$targetDir) {
         throw new \Exception("targetDir cannot be empty");
     }
     $fileBackup->directory = $service->getBaseRelativePath($targetDir);
     $name = md5($targetDir) . '.zip';
     $filename = "{$tempDir}/{$name}";
     $fileBackup->filename = $name;
     $zippy = App::make('backup.zippy');
     $tempTargetDir = tempnam(sys_get_temp_dir(), 'tmp');
     unlink($tempTargetDir);
     mkdir($tempTargetDir);
     $success = \File::copyDirectory($targetDir, $tempTargetDir);
     $zippy->create($filename, $tempTargetDir);
     $fileBackup->md5 = md5_file($filename);
     \File::deleteDirectory($tempTargetDir);
     return $fileBackup;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $namespace = "Tablas";
     //borrramos generaciones previas
     File::deleteDirectory(app_path('contraladores_generados'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('contraladores_generados'), 777);
     $this->info("Buscando modelos");
     $models = File::files(app_path('models'));
     foreach ($models as $model) {
         if (File::isFile($model)) {
             $baseText = File::get(app_path('controllers/templates/Template.txt'));
             $controllerName = str_plural_spanish(str_replace('.php', '', basename($model))) . 'Controller';
             $this->info("Generando controller: " . $controllerName);
             //replace class name..
             $baseText = str_replace('@class_name@', $controllerName, $baseText);
             //replace namespace..
             $baseText = str_replace('@namespace@', $namespace, $baseText);
             File::put(app_path('contraladores_generados/' . $controllerName . '.php'), $baseText);
         }
     }
 }
Example #23
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //borrramos generaciones previas
     File::deleteDirectory(app_path('vistas_generadas'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('vistas_generadas'), 777);
     $this->info("Buscando modelos");
     $models = File::files(app_path('models'));
     foreach ($models as $model) {
         if (File::isFile($model)) {
             $modelName = str_replace('.php', '', basename($model));
             if ($modelName != 'BaseModel') {
                 $modelInstance = new $modelName();
                 $collectionName = lcfirst(str_plural_spanish($modelName));
                 $baseText = File::get(app_path('controllers/templates/View.txt'));
                 $baseText = str_replace('@model_name@', $modelName, $baseText);
                 $baseText = str_replace('@pretty_name@', $modelInstance->getPrettyName(), $baseText);
                 $baseText = str_replace('@collection_name@', $collectionName, $baseText);
                 $basePath = app_path('vistas_generadas');
                 $this->info("Generando vista: " . $collectionName);
                 File::put($basePath . '/' . $collectionName . '.blade.php', $baseText);
                 $baseText = File::get(app_path('controllers/templates/Form.txt'));
                 $baseText = str_replace('@var_name@', lcfirst($modelName), $baseText);
                 $baseText = str_replace('@pretty_name@', $modelInstance->getPrettyName(), $baseText);
                 $baseText = str_replace('@collection_name@', $collectionName, $baseText);
                 $fieldsStr = "";
                 $fields = $modelInstance->getFillable();
                 foreach ($fields as $key) {
                     $fieldsStr .= "{{Form::btInput(\$" . lcfirst($modelName) . ", '" . $key . "', 6)}}" . PHP_EOL;
                 }
                 $baseText = str_replace('@fields@', $fieldsStr, $baseText);
                 $basePath = app_path('vistas_generadas');
                 $this->info("Generando formulario: " . $collectionName);
                 File::put($basePath . '/' . $collectionName . 'form.blade.php', $baseText);
             }
         }
     }
 }
Example #24
0
 public function getRemove()
 {
     File::deleteDirectory($_SERVER['DOCUMENT_ROOT'] . "/install");
     return Illuminate\Support\Facades\Redirect::to('/');
 }
Example #25
0
        $filePath .= ".json";
    }
    if (!File::Exists($filePath)) {
        App::abort(404, "Cannot find {$filePath}");
    }
    $content = File::get($filePath);
    return Response::make($content, 200, array('Content-Type' => 'application/json'));
});
Route::get('api-docs', function () {
    if (Config::get('swagger.generateAlways')) {
        $appDir = base_path() . "/" . Config::get('swagger.app-dir');
        $docDir = Config::get('swagger.doc-dir');
        if (!File::exists($docDir) || is_writable($docDir)) {
            // delete all existing documentation
            if (File::exists($docDir)) {
                File::deleteDirectory($docDir);
            }
            File::makeDirectory($docDir);
            $defaultBasePath = Config::get('swagger.default-base-path');
            $defaultApiVersion = Config::get('swagger.default-api-version');
            $defaultSwaggerVersion = Config::get('swagger.default-swagger-version');
            $excludeDirs = Config::get('swagger.excludes');
            $swagger = new Swagger($appDir, $excludeDirs);
            $resourceList = $swagger->getResourceList(array('output' => 'array', 'apiVersion' => $defaultApiVersion, 'swaggerVersion' => $defaultSwaggerVersion));
            $resourceOptions = array('output' => 'json', 'defaultSwaggerVersion' => $resourceList['swaggerVersion'], 'defaultBasePath' => $defaultBasePath);
            $output = array();
            foreach ($swagger->getResourceNames() as $resourceName) {
                $json = $swagger->getResource($resourceName, $resourceOptions);
                $resourceName = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($resourceName, DIRECTORY_SEPARATOR));
                $output[$resourceName] = $json;
            }
                if ($pages->count() > 1) {
                    /* foreach ($pages as $p) {
                         if(File::exists($p->page_url)){
                            File::copy($p->page_url, $path.'\\'.$p->page_shortname.'.xml');
                         } 
                       }*/
                    $files = File::files($sections->section_url);
                    $fileDetails = [];
                    foreach ($files as $f) {
                        if (File::exists($f)) {
                            $fileDetails = pathinfo($f);
                            File::copy($f, $path . '\\' . $fileDetails['basename']);
                        }
                    }
                }
                File::deleteDirectory($sections->section_url);
                if (File::exists($Uploadpath . ".zip")) {
                    File::delete($Uploadpath . ".zip");
                }
            }
        }
        if ($pages->count() > 1) {
            foreach ($pages as $p) {
                $page = DB::table('pages')->where('id', $p->id)->update(array('page_url' => public_path() . '\\' . 'sections\\' . Input::get('shortname') . '\\' . $p->page_shortname . '.xml', 'page_link_value' => Input::get('shortname') . '/' . $p->page_shortname, 'page_section' => Input::get('name_of_section'), 'page_description' => Input::get('name_of_section') . '>' . $p->page_name, 'page_subtitle' => Input::get('sub_section') . ':' . Input::get('name_of_section') . '>' . $p->page_name));
            }
        }
        $sectionsEdit = DB::table('sections')->where('id', Input::get('id'))->update(array('name_of_section' => Input::get('name_of_section'), 'sub_section' => Input::get('sub_section'), 'shortname' => Input::get('shortname'), 'section_url' => $path, 'upload_status' => ""));
        return Redirect::to('/editSection?id=' . $sections->id)->withMessage('Section edited');
        // return $pages->count();
    }
});
 public function deleteHandle($id)
 {
     $domain = Domain::find($id);
     if (Acl::isAdmin($domain) || Acl::isSuperAdmin()) {
         DB::statement('SET FOREIGN_KEY_CHECKS=0');
         $domain->siteViewers()->delete();
         $domain->domainVotes()->delete();
         $domain->delete();
         DB::statement('SET FOREIGN_KEY_CHECKS=0');
         try {
             $path_details = explode("/", $domain->thumb, 2);
             $folder = $path_details[0];
             File::deleteDirectory(public_path('assets/thumbs/' . $folder));
         } catch (Exception $e) {
         }
         return Redirect::route('domains-pending')->with('success', trans('directory.domain_deleted'));
     }
     return Redirect::back()->with('error', Lang::get('directory.delete_denied', ['domain' => $domain->name]));
 }
Example #28
0
File: Sync.php Project: larakit/lk
 protected function clearTmpDir()
 {
     if (is_dir($this->tmp_dir)) {
         \File::deleteDirectory($this->tmp_dir);
         $this->info('Удалена временная дирректория');
     }
 }
Example #29
0
 public function clear()
 {
     \File::deleteDirectory(storage_path('app'), true);
     flash()->success('Backup has been cleared');
     return redirect()->back();
 }
 public function testValidatorMessages()
 {
     $imgDir = $this->fixturesPath . '/images';
     // Create
     if (File::exists($imgDir)) {
         File::deleteDirectory($imgDir);
     }
     File::makeDirectory($imgDir);
     $faker = Faker\Factory::create($this->app['config']['locale']);
     $fixturesPath = $this->fixturesPath;
     $data = ['accepted' => false, 'required_if_cond' => true, 'active_url' => 'thispage', 'after_date' => Carbon::now()->toDateTimeString(), 'alpha' => 123, 'alpha_dash' => '&*', 'alpha_num' => '_-', 'array' => '123', 'before_date' => Carbon::now()->toDateString(), 'between_numeric' => 10, 'between_file' => new UploadedFile($fixturesPath . '/texts/test_between.txt', str_random(), null, null, null, true), 'between_string' => str_random(10), 'between_array' => range(1, 10), 'boolean' => 'string', 'confirmed_confirmation' => 'b', 'confirmed' => 'a', 'date' => 'somestring', 'date_format' => 'somestring', 'different' => 'somestring', 'digits' => 123456, 'digits_between' => 124567, 'distinct' => [1, 1, 2, 2, 3, 3], 'email' => 'notanemail', 'filled' => '', 'image' => new UploadedFile($fixturesPath . '/texts/test_between.txt', str_random(), null, null, null, true), 'in' => 'c', 'in_array' => 4, 'integer' => 4.2, 'ip' => 'a.a.a.a', 'json' => '{a:c}', 'max_numeric' => 1234567, 'max_file_plural' => new UploadedFile($fixturesPath . '/texts/test_between.txt', str_random(), null, 0, null, true), 'max_string_plural' => 'abcdefghijklmn', 'max_array_plural' => [1, 2, 3, 4, 5, 6], 'max_file_singular' => new UploadedFile($fixturesPath . '/texts/test_between.txt', str_random(), null, 5, null, true), 'max_string_singular' => 'string|max:1', 'max_array_singular' => [1, 2], 'mimes' => new UploadedFile($faker->image($this->fixturesPath . '/images'), str_random(), null, null, null, true), 'min_numeric' => 1, 'min_file' => new UploadedFile($fixturesPath . '/texts/test_empty.txt', str_random(), null, null, null, true), 'min_string' => 'a', 'min_array' => [1], 'numeric' => 'qwe', 'regex' => '-_!@#$%^&*()-=', 'required' => [], 'required_if' => null, 'required_with' => '', 'required_with_all' => '', 'required_without' => '', 'required_without_all' => '', 'same' => 'notthesame', 'size_numeric' => 12, 'size_file_plural' => new UploadedFile($fixturesPath . '/texts/test_empty.txt', str_random(), null, null, null, true), 'size_string_plural' => 'ab', 'size_array_plural' => ['a', 'b'], 'size_file_singular' => new UploadedFile($fixturesPath . '/texts/test_empty.txt', str_random(), null, null, null, true), 'size_string_singular' => 'ab', 'size_array_singular' => ['a', 'b'], 'string' => 1234, 'timezone' => 'NotATimezone'];
     $rules = ['accepted' => 'accepted', 'active_url' => 'active_url', 'after_date' => 'after:tomorrow', 'alpha' => 'alpha', 'alpha_dash' => 'alpha_dash', 'alpha_num' => 'alpha_num', 'array' => 'array', 'before_date' => 'before:yesterday', 'between_numeric' => 'numeric|between:1,5', 'between_file' => 'file|between:1,5', 'between_string' => 'between:1,5', 'between_array' => 'array|between:1,5', 'boolean' => 'boolean', 'confirmed' => 'confirmed', 'required' => 'required', 'date' => 'date', 'date_format' => 'date_format:d-m-Y H:i:s', 'different' => 'different:date', 'digits' => 'digits:5', 'digits_between' => 'digits_between:1,3', 'distinct.*' => 'distinct', 'email' => 'email', 'filled' => 'filled', 'image' => 'image', 'in' => 'in:a,b', 'in_array' => 'in_array:distinct', 'integer' => 'integer', 'ip' => 'ip', 'json' => 'json', 'max_numeric' => 'numeric|max:5', 'max_file_plural' => 'file|max:5', 'max_string_plural' => 'string|max:5', 'max_array_plural' => 'array|max:5', 'max_file_singular' => 'file|max:1', 'max_string_singular' => 'string|max:1', 'max_array_singular' => 'array|max:1', 'mimes' => 'mimes:txt,avi,html', 'min_numeric' => 'numeric|min:5', 'min_file' => 'file|min:5', 'min_string' => 'string|min:5', 'min_array' => 'array|min:5', 'numeric' => 'numeric', 'present' => 'present', 'regex' => 'regex:/^([\\w\\d]+?)$/', 'required' => 'required', 'required_if' => 'required_if:in,c', 'required_with' => 'required_with:email,ip', 'required_with_all' => 'required_with_all:email,ip', 'required_without' => 'required_without:filled,required', 'required_without_all' => 'required_without_all:filled,required', 'same' => 'same:date', 'size_numeric' => 'numeric|size:5', 'size_string_plural' => 'string|size:5', 'size_file_plural' => 'file|size:5', 'size_array_plural' => 'array|size:5', 'size_string_singular' => 'string|size:1', 'size_file_singular' => 'file|size:1', 'size_array_singular' => 'array|size:1', 'string' => 'string', 'timezone' => 'timezone'];
     $validator = Validator::make($data, $rules);
     $errors = $validator->getMessageBag();
     $this->assertFalse($validator->passes());
     $this->assertNotEmpty($errors);
     $this->assertEquals('The accepted must be accepted.', $errors->first('accepted'));
     $this->assertEquals('The active url is not a valid URL.', $errors->first('active_url'));
     $this->assertEquals('The after date must be a date after tomorrow.', $errors->first('after_date'));
     $this->assertEquals('The alpha may only contain letters.', $errors->first('alpha'));
     $this->assertEquals('The alpha dash may only contain letters, numbers, and dashes.', $errors->first('alpha_dash'));
     $this->assertEquals('The alpha num may only contain letters and numbers.', $errors->first('alpha_num'));
     $this->assertEquals('The array must be an array.', $errors->first('array'));
     $this->assertEquals('The before date must be a date before yesterday.', $errors->first('before_date'));
     $this->assertEquals('The between numeric must be between 1 and 5.', $errors->first('between_numeric'));
     $this->assertEquals('The between file must be between 1 and 5 kilobytes.', $errors->first('between_file'));
     $this->assertEquals('The between string must be between 1 and 5 characters.', $errors->first('between_string'));
     $this->assertEquals('The between array must have between 1 and 5 items.', $errors->first('between_array'));
     $this->assertEquals('The boolean field must be true or false.', $errors->first('boolean'));
     $this->assertEquals('The confirmed confirmation does not match.', $errors->first('confirmed'));
     $this->assertEquals('The date is not a valid date.', $errors->first('date'));
     $this->assertEquals('The date format does not match the format d-m-Y H:i:s.', $errors->first('date_format'));
     $this->assertEquals('The different and date must be different.', $errors->first('different'));
     $this->assertEquals('The digits must be 5 digits.', $errors->first('digits'));
     $this->assertEquals('The digits between must be between 1 and 3 digits.', $errors->first('digits_between'));
     $this->assertEquals('The distinct.0 field has a duplicate value.', $errors->first('distinct.0'));
     $this->assertEquals('The email must be a valid email address.', $errors->first('email'));
     $this->assertEquals('The filled field is required.', $errors->first('filled'));
     $this->assertEquals('The image must be an image.', $errors->first('image'));
     $this->assertEquals('The selected in is invalid.', $errors->first('in'));
     $this->assertEquals('The in array field does not exist in distinct.', $errors->first('in_array'));
     $this->assertEquals('The integer must be an integer.', $errors->first('integer'));
     $this->assertEquals('The ip must be a valid IP address.', $errors->first('ip'));
     $this->assertEquals('The json must be a valid JSON string.', $errors->first('json'));
     $this->assertEquals('The max numeric may not be greater than 5.', $errors->first('max_numeric'));
     $this->assertEquals('The max file singular may not be greater than 1 kilobyte.', $errors->first('max_file_singular'));
     $this->assertEquals('The max string singular may not be greater than 1 character.', $errors->first('max_string_singular'));
     $this->assertEquals('The max array singular may not have more than 1 item.', $errors->first('max_array_singular'));
     $this->assertEquals('The max file plural may not be greater than 5 kilobytes.', $errors->first('max_file_plural'));
     $this->assertEquals('The max string plural may not be greater than 5 characters.', $errors->first('max_string_plural'));
     $this->assertEquals('The max array plural may not have more than 5 items.', $errors->first('max_array_plural'));
     $this->assertEquals('The mimes must be a file of type: txt,avi,html.', $errors->first('mimes'));
     $this->assertEquals('The min numeric must be at least 5.', $errors->first('min_numeric'));
     $this->assertEquals('The min file must be at least 5 kilobytes.', $errors->first('min_file'));
     $this->assertEquals('The min string must be at least 5 characters.', $errors->first('min_string'));
     $this->assertEquals('The min array must have at least 5 items.', $errors->first('min_array'));
     $this->assertEquals('The numeric must be a number.', $errors->first('numeric'));
     $this->assertEquals('The present field must be present.', $errors->first('present'));
     $this->assertEquals('The regex format is invalid.', $errors->first('regex'));
     $this->assertEquals('The required field is required.', $errors->first('required'));
     $this->assertEquals('The required if field is required when in is c.', $errors->first('required_if'));
     $this->assertEquals('The required with field is required when email / ip is present.', $errors->first('required_with'));
     $this->assertEquals('The required with all field is required when email / ip is present.', $errors->first('required_with_all'));
     $this->assertEquals('The required without field is required when filled / required is not present.', $errors->first('required_without'));
     $this->assertEquals('The required without all field is required when none of filled / required are present.', $errors->first('required_without_all'));
     $this->assertEquals('The same and date must match.', $errors->first('same'));
     $this->assertEquals('The size numeric must be 5.', $errors->first('size_numeric'));
     $this->assertEquals('The size string singular must be 1 character.', $errors->first('size_string_singular'));
     $this->assertEquals('The size file singular must be 1 kilobyte.', $errors->first('size_file_singular'));
     $this->assertEquals('The size array singular must contain 1 item.', $errors->first('size_array_singular'));
     $this->assertEquals('The size string plural must be 5 characters.', $errors->first('size_string_plural'));
     $this->assertEquals('The size file plural must be 5 kilobytes.', $errors->first('size_file_plural'));
     $this->assertEquals('The size array plural must contain 5 items.', $errors->first('size_array_plural'));
     $this->assertEquals('The string must be a string.', $errors->first('string'));
     $this->assertEquals('The timezone must be a valid zone.', $errors->first('timezone'));
     // Delete temporary images directory
     File::deleteDirectory($imgDir);
 }