/** * Execute the console command. * * @return mixed */ public function handle() { try { $sourceDir = __DIR__ . "/../testing"; $destinationDir = "config/testing"; $testcase_main = "tests/TestCase.php"; if (File::exists($testcase_main)) { $get_contents = __DIR__ . "/../BaseTestcase/Testcase.php"; if (File::exists($get_contents)) { $success = File::copyDirectory($sourceDir, $destinationDir); file_put_contents($testcase_main, file_get_contents($get_contents)); if ($success) { $this->info("Testing directory for local database( Temporary Storage ) is successfully created"); } else { $this->error("There was an error in creating local testing folder"); } } else { $this->error("No file in package directory"); } } else { $this->error("No file in tests directory"); } } catch (\Exception $e) { die("The base file doesn't exist"); } }
public function fire() { $name = strtolower($this->argument('name')); $stubs = __DIR__ . '/stubs/view'; $path = base_path('resources/themes/gokyuzu/views/admin/' . $name); File::copyDirectory($stubs, $path); }
/** * Publish the views */ protected function publishViews() { $views = dirname(__FILE__) . '/../Views'; $location = base_path('resources/views/vendor/vault'); //Publishes the views to the resources path, since laravel checks for both, this lets the user alter them return File::copyDirectory($views, $location); }
/** * Execute the console command. * * @access public * @return mixed */ public function fire() { $source = realpath(__DIR__ . '/../views'); $destination = app_path('views/bauhaus'); File::copyDirectory($source, $destination); $this->info(sprintf('Views exported to `%s`', $destination)); }
/** * Execute the console command. * * @return mixed */ public function handle() { // Start the progress bar $bar = $this->helper->barSetup($this->output->createProgressBar(7)); $bar->start(); // Common variables $vendor = strtolower($this->argument('vendor')); $name = strtolower($this->argument('name')); $path = getcwd() . '/packages/'; $fullPath = $path . $vendor . '/' . $name; $cVendor = studly_case($vendor); $cName = studly_case($name); $requirement = '"psr-4": { "' . $cVendor . '\\\\' . $cName . '\\\\": "packages/' . $vendor . '/' . $name . '/src",'; $appConfigLine = 'App\\Providers\\RouteServiceProvider::class, ' . $cVendor . '\\' . $cName . '\\' . 'ServiceProvider::class,'; // Start creating the package $this->info('Creating package ' . $vendor . '\\' . $name . '...'); if (!$this->option('force')) { $this->helper->checkExistingPackage($path, $vendor, $name); } $bar->advance(); // Create the package directory $this->info('Creating packages directory...'); $this->helper->makeDir($path); $bar->advance(); // Create the vendor directory $this->info('Creating vendor...'); $this->helper->makeDir($path . $vendor); $bar->advance(); // Copying package skeleton $this->info('Copying package skeleton...'); File::copyDirectory(__DIR__ . '/../skeleton', $fullPath); foreach (File::allFiles($fullPath) as $file) { $search = [':vendor_name', ':VendorName', ':package_name', ':PackageName']; $replace = [$vendor, $cVendor, $name, $cName]; $newfile = substr($file, 0, -5); $this->helper->replaceAndSave($file, $search, $replace, $newfile, $deleteOldFile = true); } $bar->advance(); // Add it to composer.json $this->info('Adding package to composer and app...'); $this->helper->replaceAndSave(getcwd() . '/composer.json', '"psr-4": {', $requirement); //And add it to the providers array in config/app.php $this->helper->replaceAndSave(getcwd() . '/config/app.php', 'App\\Providers\\RouteServiceProvider::class,', $appConfigLine); $bar->advance(); // Finished creating the package, end of the progress bar $bar->finish(); $this->info('Package created successfully!'); $this->output->newLine(2); $bar = null; }
public function handle() { if (($table = $this->option('table')) === null) { $tables = $this->DBHelper->listTables(); $table = $this->choice('Choose table:', $tables, null); } $columns = collect($this->DBHelper->listColumns($table)); $this->transformer->setColumns($columns); $namespace = config('thunderclap.namespace'); $moduleName = str_replace('_', '', title_case($table)); $containerPath = config('thunderclap.target_dir', base_path('modules')); $modulePath = $containerPath . DIRECTORY_SEPARATOR . $moduleName; // 1. check existing module if (is_dir($modulePath)) { $overwrite = $this->confirm("Folder {$modulePath} already exist, do you want to overwrite it?"); if ($overwrite) { File::deleteDirectory($modulePath); } else { return false; } } // 2. create modules directory $this->info('Creating modules directory...'); $this->packerHelper->makeDir($containerPath); $this->packerHelper->makeDir($modulePath); // 3. copy module skeleton $stubs = __DIR__ . '/../../stubs'; $this->info('Copying module skeleton into ' . $modulePath); File::copyDirectory($stubs, $modulePath); $templates = ['module-name' => str_replace('_', '-', $table), 'route-prefix' => config('thunderclap.routes.prefix')]; // 4. rename file and replace common string $search = [':Namespace:', ':module_name:', ':module-name:', ':module name:', ':Module Name:', ':moduleName:', ':ModuleName:', ':FILLABLE:', ':TRANSFORMER_FIELDS:', ':VALIDATION_RULES:', ':LANG_FIELDS:', ':TABLE_HEADERS:', ':TABLE_FIELDS:', ':DETAIL_FIELDS:', ':FORM_CREATE_FIELDS:', ':FORM_EDIT_FIELDS:', ':VIEW_EXTENDS:', ':route-prefix:', ':route-middleware:', ':route-url-prefix:']; $replace = [$namespace, snake_case($table), $templates['module-name'], str_replace('_', ' ', strtolower($table)), ucwords(str_replace('_', ' ', $table)), str_replace('_', '', camel_case($table)), str_replace('_', '', title_case($table)), $this->transformer->toFillableFields(), $this->transformer->toTransformerFields(), $this->transformer->toValidationRules(), $this->transformer->toLangFields(), $this->transformer->toTableHeaders(), $this->transformer->toTableFields(), $this->transformer->toDetailFields(), $this->transformer->toFormCreateFields(), $this->transformer->toFormUpdateFields(), config('thunderclap.view.extends'), $templates['route-prefix'], $this->toArrayElement(config('thunderclap.routes.middleware')), $this->getRouteUrlPrefix($templates['route-prefix'], $templates['module-name'])]; foreach (File::allFiles($modulePath) as $file) { if (is_file($file)) { $newFile = $deleteOriginal = false; if (Str::endsWith($file, '.stub')) { $newFile = Str::substr($file, 0, -5); $deleteOriginal = true; } $this->packerHelper->replaceAndSave($file, $search, $replace, $newFile, $deleteOriginal); } } $this->warn('Add following service provider to config/app.php ====> ' . $namespace . '\\' . ucwords(str_replace('_', ' ', $table)) . '\\ServiceProvider::class,'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Hello Migration.'); $packages = config('build.universe.packages'); if (count($packages) == 0) { $this->error('No packages found in unverse config.'); return; } $paths = ServiceProvider::pathsToPublish(); foreach ($paths as $sourceDir => $destinationDir) { if (substr($destinationDir, -10) == 'migrations') { if (File::copyDirectory($sourceDir, $destinationDir)) { $this->info("copied {$sourceDir}"); } } } $this->info('Done.'); }
/** * Execute the console command. * * @return mixed */ public function fire() { $from = $this->argument('from_locale'); $to = $this->argument('to_locale'); $Lari18n = Lari18n::getInstance(); $data = $Lari18n->retrieveI18nData(); $languages = $data['languages']; $languagesPath = $data['paths']['lang']; // check if (!in_array($from, $languages)) { $this->error('There is no locale [' . $from . ']'); } if (in_array($to, $languages)) { $this->error('The [' . $to . '] locale already exist'); } // Create the new language directory File::copyDirectory($languagesPath . '/' . $from, $languagesPath . '/' . $to); $files = File::allFiles($languagesPath . '/' . $to); $Lari18n->reinitialiseFiles($files, $to); $this->info('The [' . $to . '] translation directory as been created from [' . $from . '] translations files'); }
public static function fire(SetupCommand $setupCommand) { $run = new self(); File::copyDirectory(__DIR__ . '/../deployment', base_path() . '/deployment'); $setupCommand->info("Deployment folder made"); }
/** * Generates the assets directory * by copying the files from the template directory to a public diretory * * @param string $content * @return void */ private function generateAssetsDirectory() { $destinationPath = public_path() . '/assets/docs/' . $this->dotPrefix; // create assets directory File::makeDirectory($destinationPath, $mode = 0777, true, true); $targetPath = Config::get('apidocs.assets_path'); $directories = ['css', 'img', 'js']; foreach ($directories as $directory) { $target = $targetPath . '/' . $directory; $dest = $destinationPath . '/' . $directory; File::copyDirectory($target, $dest); } }
protected function installFrontend() { File::copyDirectory($this->stubs('app/Http/Controllers/Frontend'), app_path('Http/Controllers/Frontend')); File::copyDirectory($this->stubs('resources/views/frontend'), base_path('resources/views/frontend')); }
protected function setupFolder(SetupCommand $setupCommand) { File::copyDirectory(__DIR__ . '/../server_config', base_path() . '/server_config'); $setupCommand->info("Server Config /server_config folder made"); }
/** * Configure Vue. * * @return void */ protected function setUpVue() { $this->describeMethod('Setup Vue'); File::copyDirectory("{$this->packagePath}/vue/components", "{$this->vuePath}/components"); $this->reportStep('copy vue files to app', 'SUCCESS'); $report = VueAssembler::web()->addComponent('navbar', './components/NavbarComponent.vue'); $report = VueAssembler::web()->addComponent('flash-alert', './components/FlashAlert.vue'); $this->reportStep('require NavbarComponent in web.js', $report); }
/** * Copy all model files from the stub * * @return void */ protected function copyModelStubs() { File::copyDirectory($this->getStubsFolder() . '/models', $this->getModelDestinationFolder()); $this->reportStep('copy all model stubs', 'SUCCESS'); }
/** * Copy Less folders */ protected function copyLessFolders() { foreach ($this->lessSources as $source => $destination) { $this->line('<info>LESS:</info> ' . base_path($destination)); File::copyDirectory(base_path($source), base_path($destination)); } }
public function postStore() { $sid = \Input::get('id'); $rules = array('image' => 'mimes:jpg,jpeg,png,gif|max:500', 'name' => 'required|unique:medias,name' . (isset($sid) ? ',' . $sid : ''), 'short_description' => 'required', 'sku' => 'required|alpha_dash|unique:medias,sku' . (isset($sid) ? ',' . $sid : ''), 'category_id' => 'required|numeric|min:1', 'tags' => 'regex:/^[a-z,0-9 -]+$/i'); $messages = ['category_id.min' => 'The category field is required.']; $validation = \Validator::make(\Input::all(), $rules, $messages); if ($validation->fails()) { return redirect('admin/medias/' . (isset($sid) ? 'edit/' . $sid : 'create'))->withErrors($validation)->withInput(); } $name = \Input::get('name'); $sku = \Input::get('sku'); $short_description = \Input::get('short_description'); $long_description = \Input::get('long_description'); $image = \Input::file('image'); $featured = \Input::get('featured') == '' ? false : true; $active = \Input::get('active') == '' ? false : true; $category_id = \Input::get('category_id'); $tags = \Input::get('tags'); $media = isset($sid) ? Media::find($sid) : new Media(); if ($media == null) { $errors = new \Illuminate\Support\MessageBag(); $errors->add('editError', "The media cannot be found because it does not exist or may have been deleted."); return redirect('/admin/medias')->withErrors($errors); } $media->name = $name; $media->sku = $sku; $media->short_description = $short_description; $media->long_description = $long_description; $media->featured = $featured; $media->active = $active; if (isset($sid)) { // Check if category has changed if ($media->category_id != $category_id) { $old_cat_folder = public_path() . '/assets/medias/' . $media->category_id . '/' . $sid; $new_cat_folder = public_path() . '/assets/medias/' . $category_id . '/' . $sid; // Create the directory if (!file_exists($new_cat_folder)) { mkdir($new_cat_folder, 0777, true); } // Copy existing media to new category File::copyDirectory($old_cat_folder, $new_cat_folder); // Delete old media folder File::deleteDirectory($old_cat_folder); } } else { $media->path = 'broken.pdf'; } $media->category_id = $category_id; // Create or save changes $media->save(); // Save translations $translations = \Config::get('redminportal::translation'); foreach ($translations as $translation) { $lang = $translation['lang']; if ($lang == 'en') { continue; } $translated_content = array('name' => \Input::get($lang . '_name'), 'short_description' => \Input::get($lang . '_short_description'), 'long_description' => \Input::get($lang . '_long_description')); // Check if lang exist $translated_model = $media->translations->where('lang', $lang)->first(); if ($translated_model == null) { $translated_model = new Translation(); } $translated_model->lang = $lang; $translated_model->content = json_encode($translated_content); $media->translations()->save($translated_model); } if (!empty($tags)) { // Delete old tags $media->tags()->detach(); // Save tags foreach (explode(',', $tags) as $tagName) { Tag::addTag($media, $tagName); } } if (\Input::hasFile('image')) { //Upload the file $helper_image = new RImage(); $filename = $helper_image->upload($image, 'medias/' . $media->id, true); if ($filename) { // create photo $newimage = new Image(); $newimage->path = $filename; // save photo to the loaded model $media->images()->save($newimage); } } return redirect('admin/medias'); }