Exemplo n.º 1
0
 public function fire()
 {
     $stubs = __DIR__ . '/stubs/lang.stub';
     $name = strtolower($this->argument('name'));
     $path = base_path('resources/lang/tr/admin/' . $name . '.php');
     File::copy($stubs, $path);
 }
Exemplo n.º 2
0
 public function download($id)
 {
     $file = File::findOrFail($id);
     $pathToFile = 'get_link_to_download/' . md5($file->name . time());
     FileHelpers::copy(storage_path('app') . '/' . $file->local_name, $pathToFile);
     return response()->download($pathToFile, $file->name, ['Content-Type'])->deleteFileAfterSend(true);
 }
Exemplo n.º 3
0
 /**
  * Publish seeds for testing
  */
 public function testPublishedSeeds()
 {
     $source = __DIR__ . '/../src/Database/seeds/CountriesTableSeeder.php';
     $destination = database_path('seeds/CountriesTableSeeder.php');
     File::copy($source, $destination);
     $success = File::exists($destination);
     $this->assertTrue($success);
 }
 /**
  * Perform the conversion.
  *
  * @param \Spatie\MediaLibrary\Media $media
  * @param Conversion $conversion
  * @param string $copiedOriginalFile
  *
  * @return string
  */
 public function performConversion(Media $media, Conversion $conversion, string $copiedOriginalFile)
 {
     $conversionTempFile = pathinfo($copiedOriginalFile, PATHINFO_DIRNAME) . '/' . string()->random(16) . $conversion->getName() . '.' . $media->extension;
     File::copy($copiedOriginalFile, $conversionTempFile);
     foreach ($conversion->getManipulations() as $manipulation) {
         GlideImage::create($conversionTempFile)->modify($manipulation)->save($conversionTempFile);
     }
     return $conversionTempFile;
 }
 /**
  * Perform the conversion.
  *
  * @param \Spatie\MediaLibrary\Media $media
  * @param Conversion                 $conversion
  * @param string                     $copiedOriginalFile
  *
  * @return string
  */
 public function performConversion(Media $media, Conversion $conversion, $copiedOriginalFile)
 {
     $conversionTempFile = pathinfo($copiedOriginalFile, PATHINFO_DIRNAME) . '/' . string()->random(16) . $conversion->getName() . '.' . $media->extension;
     File::copy($copiedOriginalFile, $conversionTempFile);
     foreach ($conversion->getManipulations() as $manipulation) {
         (new GlideImage())->load($conversionTempFile, $manipulation)->useAbsoluteSourceFilePath()->save($conversionTempFile);
     }
     return $conversionTempFile;
 }
Exemplo n.º 6
0
 protected function setupBower(SetupCommand $setupCommand)
 {
     File::copy(base_path() . '/deployment/stubs/.bowerrc', base_path() . '/.bowerrc');
     File::copy(base_path() . '/deployment/stubs/bower.json', base_path() . '/bower.json');
     File::copy(base_path() . '/deployment/stubs/package.json', base_path() . '/package.json');
     $setupCommand->info("Added bower and bower.json.");
     exec('npm install');
     exec('bower install');
 }
Exemplo n.º 7
0
 /**
  * Store the compiled stub.
  *
  * @param $modelName
  * @param \stdClass $scaffolderConfig
  * @param $compiled
  * @param \Scaffolder\Support\FileToCompile $fileToCompile
  *
  * @return string
  */
 protected function store($modelName, stdClass $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
 {
     $path = PathParser::parse($scaffolderConfig->paths->migrations) . $this->date->format('Y_m_d_His') . '_create_' . strtolower($modelName) . 's_table.php';
     // Store in cache
     if ($fileToCompile->cached) {
         File::copy(base_path('scaffolder-config/cache/migration_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     } else {
         File::put(base_path('scaffolder-config/cache/migration_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
         File::copy(base_path('scaffolder-config/cache/migration_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     }
     return $path;
 }
 protected function _saveModel($model, $filename)
 {
     $fullDestinationPath = $model->getFullPathToFolder();
     $imageSize = @getimagesize($fullDestinationPath . '/' . $filename);
     if (is_array($imageSize)) {
         File::copy($fullDestinationPath . '/' . $filename, $fullDestinationPath . '/original_' . $filename);
         $size = array('width' => $imageSize[0], 'height' => $imageSize[1]);
         $model->size = $size;
         $model->origin_size = $size;
     }
     $model->uploader_id = Auth::user()->id;
 }
Exemplo n.º 9
0
 /**
  * Store the compiled stub.
  *
  * @param               $modelName
  * @param               $scaffolderConfig
  * @param               $compiled
  * @param FileToCompile $fileToCompile
  *
  * @return string
  */
 protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
 {
     $path = PathParser::parse($scaffolderConfig->paths->models) . $modelName . '.php';
     // Store in cache
     if ($fileToCompile->cached) {
         File::copy(base_path('scaffolder-config/cache/model_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     } else {
         File::put(base_path('scaffolder-config/cache/model_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
         File::copy(base_path('scaffolder-config/cache/model_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     }
     return $path;
 }
Exemplo n.º 10
0
 private function copy_zip()
 {
     $src = $this->zip_path . '.zip';
     $dst = config('tools.package_path') . $this->fontname . '/src/resources/assets/font/fontello.zip';
     if (File::exists(config('tools.package_path') . $this->fontname)) {
         if (File::copy($src, $dst)) {
             $this->info("copied: {$src} => {$dst}.");
         } else {
             $this->info("failed: {$src} => {$dst}.");
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Store the compiled stub.
  *
  * @param               $modelName
  * @param               $scaffolderConfig
  * @param               $compiled
  * @param FileToCompile $fileToCompile
  *
  * @return string
  */
 protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
 {
     $path = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) . '/create.blade.php';
     // Store in cache
     if ($fileToCompile->cached) {
         File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     } else {
         File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
         File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     }
     return $path;
 }
Exemplo n.º 12
0
 /**
  * Store the compiled stub.
  *
  * @param $modelName
  * @param \stdClass $scaffolderConfig
  * @param $compiled
  * @param \Scaffolder\Support\FileToCompile $fileToCompile
  *
  * @return string
  */
 protected function store($modelName, stdClass $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
 {
     $path = base_path('../' . strtolower(str_replace(' ', '-', $scaffolderConfig->name . '-api'))) . '/app/Models/' . $modelName . '.php';
     // Store in cache
     if ($fileToCompile->cached) {
         File::copy(base_path('scaffolder-config/cache/api_model_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     } else {
         File::put(base_path('scaffolder-config/cache/api_model_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
         File::copy(base_path('scaffolder-config/cache/api_model_' . $fileToCompile->hash . self::CACHE_EXT), $path);
     }
     return $path;
 }
Exemplo n.º 13
0
 /**
  * Configure Style.
  *     
  * @return void
  */
 protected function setUpStyle()
 {
     $this->describeMethod('Setup Stylus');
     File::copyDirectory("{$this->packagePath}/stylus/vars", "{$this->stylePath}/basecamp/vars");
     $this->reportStep('copy basecamp-design lib-files', 'SUCCESS');
     File::copy("{$this->packagePath}/stylus/design.styl", "{$this->stylePath}/basecamp/design.styl");
     $this->reportStep('copy design.styl template', 'SUCCESS');
     $assemblerFile = $this->stylePath . '/basecamp/design.styl';
     $report = FileModifier::open($assemblerFile)->replace("framework : './'", "framework : '../../../../vendor/patrikkernke/basecamp-design/src/stylus/'")->save();
     $this->reportStep('change relative path and point to composer package in design.styl', $report);
     $report = StyleAssembler::web()->addLibrary('basecamp/design');
     $this->reportStep("require basecamp/design in web.styl", $report);
 }
Exemplo n.º 14
0
 public function storeCustomRecord($parameters)
 {
     if ($this->request->hasFile('attachment')) {
         $filename = Miscellaneous::uploadFiles('attachment', public_path() . '/packages/syscover/octopus/storage/attachment/request');
     } elseif ($this->request->has('attachment')) {
         File::copy(public_path() . '/packages/syscover/octopus/storage/attachment/stock/' . $this->request->input('attachment'), public_path() . '/packages/syscover/octopus/storage/attachment/request/' . $this->request->input('attachment'));
         $filename = $this->request->input('attachment');
     }
     $octopusRequest = OctopusRequest::create(['supervisor_id_078' => $this->request->input('supervisor'), 'customer_id_078' => $this->request->input('customer'), 'shop_id_078' => $this->request->input('shopId'), 'company_id_078' => $this->request->input('company'), 'family_id_078' => $this->request->input('family'), 'brand_id_078' => $this->request->input('brand'), 'product_id_078' => $this->request->input('product'), 'address_id_078' => $this->request->has('aliasId') ? $this->request->input('aliasId') : null, 'company_name_078' => $this->request->has('companyName') ? $this->request->input('companyName') : null, 'name_078' => $this->request->has('name') ? $this->request->input('name') : null, 'surname_078' => $this->request->has('surname') ? $this->request->input('surname') : null, 'country_id_078' => $this->request->input('country'), 'territorial_area_1_id_078' => $this->request->has('territorialArea1') ? $this->request->input('territorialArea1') : null, 'territorial_area_2_id_078' => $this->request->has('territorialArea2') ? $this->request->input('territorialArea2') : null, 'territorial_area_3_id_078' => $this->request->has('territorialArea3') ? $this->request->input('territorialArea3') : null, 'cp_078' => $this->request->has('cp') ? $this->request->input('cp') : null, 'locality_078' => $this->request->has('locality') ? $this->request->input('locality') : null, 'address_078' => $this->request->has('address') ? $this->request->input('address') : null, 'phone_078' => $this->request->has('phone') ? $this->request->input('phone') : null, 'email_078' => $this->request->has('email') ? $this->request->input('email') : null, 'observations_078' => $this->request->has('observations') ? $this->request->input('observations') : null, 'date_078' => \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('date'))->getTimestamp(), 'date_text_078' => $this->request->input('date'), 'view_width_078' => $this->request->input('viewWidth'), 'view_height_078' => $this->request->input('viewHeight'), 'total_width_078' => $this->request->has('totalWidth') ? $this->request->input('totalWidth') : null, 'total_height_078' => $this->request->has('totalHeight') ? $this->request->input('totalHeight') : null, 'units_078' => $this->request->input('units'), 'expiration_078' => $this->request->has('expiration') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('expiration'))->getTimestamp() : null, 'expiration_text_078' => $this->request->has('expiration') ? $this->request->input('expiration') : null, 'attachment_078' => isset($filename) ? $filename : null, 'comments_078' => $this->request->has('comments') ? $this->request->input('comments') : null]);
     // si la peticion proviene de un stock, damos por expirado el stock duplicado
     if ($this->request->has('stock')) {
         Stock::where('id_080', $this->request->input('stock'))->update(['expiration_080' => date('U'), 'expiration_text_080' => date(config('pulsar.datePattern'))]);
     }
     $this->sendRequestEmail($octopusRequest->id_078, 'store');
 }
Exemplo n.º 15
0
 protected function setupDB(SetupCommand $setupCommand)
 {
     if (File::exists(base_path() . '/database/stubdb.sqlite')) {
         File::delete(base_path() . '/database/stubdb.sqlite');
     }
     File::put(base_path() . '/database/stubdb.sqlite', '');
     if (File::exists(base_path() . '/database/testing.sqlite')) {
         File::delete(base_path() . '/database/testing.sqlite');
     }
     /**
      * @TODO Replace this with artisan command
      */
     $command = "sh " . base_path() . '/deployment/migrate_testing.sh';
     exec($command);
     File::copy(base_path() . '/database/stubdb.sqlite', base_path() . '/database/testing.sqlite');
     $setupCommand->info("Testing db info added");
 }
Exemplo n.º 16
0
 public static function uploadFile($file, $folder, $name)
 {
     $extension = $file->getClientOriginalExtension();
     // Verify if directory exists
     if (!is_dir($folder)) {
         // Create directory
         $oldmask = umask(0);
         mkdir($folder, 0777);
         umask($oldmask);
     }
     $url = $folder . '/' . $name . '.' . $extension;
     if (File::copy($file, $url)) {
         return compact('url', 'extension');
     } else {
         return false;
     }
 }
Exemplo n.º 17
0
 public function storeCustomRecord($parameters)
 {
     if ($this->request->hasFile('attachment')) {
         $filename = Miscellaneous::uploadFiles('attachment', public_path() . '/packages/syscover/octopus/storage/attachment/stock');
     } elseif ($this->request->has('attachment')) {
         File::copy(public_path() . '/packages/syscover/octopus/storage/attachment/order/' . $this->request->input('attachment'), public_path() . '/packages/syscover/octopus/storage/attachment/stock/' . $this->request->input('attachment'));
         $filename = $this->request->input('attachment');
     }
     $stock = Stock::create(['request_id_080' => $this->request->input('request'), 'order_id_080' => $this->request->input('order'), 'supervisor_id_080' => $this->request->input('supervisor'), 'customer_id_080' => $this->request->input('customer'), 'shop_id_080' => $this->request->input('shopId'), 'company_id_080' => $this->request->input('company'), 'family_id_080' => $this->request->input('family'), 'brand_id_080' => $this->request->input('brand'), 'product_id_080' => $this->request->input('product'), 'laboratory_id_080' => $this->request->input('laboratory'), 'address_id_080' => $this->request->has('aliasId') ? $this->request->input('aliasId') : null, 'company_name_080' => $this->request->has('companyName') ? $this->request->input('companyName') : null, 'name_080' => $this->request->has('name') ? $this->request->input('name') : null, 'surname_080' => $this->request->has('surname') ? $this->request->input('surname') : null, 'country_id_080' => $this->request->input('country'), 'territorial_area_1_id_080' => $this->request->has('territorialArea1') ? $this->request->input('territorialArea1') : null, 'territorial_area_2_id_080' => $this->request->has('territorialArea2') ? $this->request->input('territorialArea2') : null, 'territorial_area_3_id_080' => $this->request->has('territorialArea3') ? $this->request->input('territorialArea3') : null, 'cp_080' => $this->request->has('cp') ? $this->request->input('cp') : null, 'locality_080' => $this->request->has('locality') ? $this->request->input('locality') : null, 'address_080' => $this->request->has('address') ? $this->request->input('address') : null, 'phone_080' => $this->request->has('phone') ? $this->request->input('phone') : null, 'email_080' => $this->request->has('email') ? $this->request->input('email') : null, 'observations_080' => $this->request->has('observations') ? $this->request->input('observations') : null, 'date_080' => \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('date'))->getTimestamp(), 'date_text_080' => $this->request->input('date'), 'view_height_080' => $this->request->input('viewHeight'), 'view_width_080' => $this->request->input('viewWidth'), 'total_height_080' => $this->request->has('totalWidth') ? $this->request->input('totalWidth') : null, 'total_width_080' => $this->request->has('totalHeight') ? $this->request->input('totalHeight') : null, 'units_080' => $this->request->input('units'), 'expiration_080' => $this->request->has('expiration') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('expiration'))->getTimestamp() : null, 'expiration_text_080' => $this->request->has('expiration') ? $this->request->input('expiration') : null, 'attachment_080' => isset($filename) ? $filename : null, 'comments_080' => $this->request->has('comments') ? $this->request->input('comments') : null]);
     RequestModel::where('id_078', $this->request->input('request'))->update(['stock_id_078' => $stock->id_080]);
     Order::where('id_079', $this->request->input('order'))->update(['stock_id_079' => $stock->id_080]);
     $actions = $this->request->route()->getAction();
     if ($actions['resource'] === 'octopus-laboratory-stock') {
         // redirect to orders
         return redirect()->route('octopusLaboratoryOrder')->with(['msg' => 1, 'txtMsg' => trans('pulsar::pulsar.message_create_record_successful', ['name' => $stock->id_080])]);
     }
 }
Exemplo n.º 18
0
 /**
  *  Function to get attachment element with json string to new element
  *
  * @access	public
  * @param   string      $routesConfigFile
  * @param   string      $resource
  * @param   integer     $objectId
  * @param   string      $lang
  * @param   boolean     $copyAttachment
  * @return  array       $response
  */
 public static function getRecords($routesConfigFile, $resource, $objectId, $lang, $copyAttachment = false)
 {
     $response['attachments'] = Attachment::getRecords(['lang_id_016' => $lang, 'resource_id_016' => $resource, 'object_id_016' => $objectId, 'orderBy' => ['column' => 'sorting_016', 'order' => 'asc']]);
     $attachmentsInput = [];
     foreach ($response['attachments'] as &$attachment) {
         $tmpFileName = null;
         if ($copyAttachment) {
             // function to duplicate files if we create a new lang object
             // copy attachments base lang article to temp folder
             $tmpFileName = uniqid();
             File::copy(public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId . '/' . base_lang()->id_001 . '/' . $attachment->file_name_016, public_path() . config($routesConfigFile . '.tmpFolder') . '/' . $tmpFileName);
             // store tmp file name in attachment to know temporal name
             $attachment['tmp_file_name_016'] = $tmpFileName;
         }
         // get json data from attachment
         $attachmentData = json_decode($attachment->data_016);
         $attachmentsInput[] = ['id' => $attachment->id_016, 'family' => $attachment->family_id_016, 'type' => ['id' => $attachment->type_id_016, 'name' => $attachment->type_text_016, 'icon' => $attachmentData->icon], 'mime' => $attachment->mime_016, 'name' => $attachment->name_016, 'folder' => $copyAttachment ? config($routesConfigFile . '.tmpFolder') : config($routesConfigFile . '.attachmentFolder') . '/' . $attachment->object_id_016 . '/' . $attachment->lang_id_016, 'tmpFileName' => $tmpFileName, 'fileName' => $attachment->file_name_016, 'width' => $attachment->width_016, 'height' => $attachment->height_016, 'library' => $attachment->library_id_016, 'libraryFileName' => $attachment->library_file_name_016, 'sorting' => $attachment->sorting_016];
     }
     $response['attachmentsInput'] = json_encode($attachmentsInput);
     return $response;
 }
Exemplo n.º 19
0
 public function build()
 {
     $script = '';
     foreach ($this->getUrlToFileTable() as $path) {
         $script .= $this->compile($path) . PHP_EOL;
     }
     if (!$this->isMinify) {
         file_put_contents($this->filename, $script);
         return;
     }
     $output = "{$this->tmp}/bin/";
     if (!file_exists($output)) {
         File::makeDirectory($output, 0777, true);
     }
     if (!file_exists(dirname($this->filename))) {
         ld($this->filename);
         File::makeDirectory(dirname($this->filename), 0777, true);
     }
     $output .= basename($this->filename);
     file_put_contents($output, $script);
     File::copy($this->minify($output), $this->filename);
 }
Exemplo n.º 20
0
 public function storeAttachmentLibrary()
 {
     $parameters = $this->request->route()->parameters();
     $files = $this->request->input('files');
     $objects = [];
     $objectsResponse = [];
     $filesNames = [];
     foreach ($files as $file) {
         // create tmp name
         $tmpFileName = uniqid();
         File::copy(public_path() . config($this->request->input('routesConfigFile') . '.libraryFolder') . '/' . $file['name'], public_path() . config($this->request->input('routesConfigFile') . '.tmpFolder') . '/' . $tmpFileName);
         $width = null;
         $height = null;
         if ($file['isImage'] == 'true') {
             list($width, $height) = getimagesize(public_path() . config($this->request->input('routesConfigFile') . '.libraryFolder') . '/' . $file['name']);
         }
         $type = ImageManagerLibrary::getMimeIconImage($file['mime']);
         $objects[] = ['resource_id_014' => $this->request->input('resource'), 'url_014' => null, 'file_name_014' => $file['name'], 'mime_014' => $file['mime'], 'size_014' => $file['size'], 'type_id_014' => $type['id'], 'type_text_014' => $type['name'], 'width_014' => $width, 'height_014' => $height, 'data_014' => json_encode(['icon' => $type['icon']])];
         if ($file['name'] != null && $file['name'] != "") {
             $filesNames[] = $file['name'];
         }
         // convert json format to store in document DOM
         $objectsResponse[] = ['id' => null, 'family' => null, 'type' => $type, 'mime' => $file['mime'], 'url' => null, 'name' => null, 'folder' => config($this->request->input('routesConfigFile') . '.tmpFolder'), 'tmpFileName' => $tmpFileName, 'fileName' => $file['name'], 'width' => $width, 'height' => $height];
     }
     AttachmentLibrary::insert($objects);
     $lastLibraryInsert = AttachmentLibrary::whereIn('file_name_014', $filesNames)->get();
     foreach ($lastLibraryInsert as $library) {
         foreach ($objectsResponse as &$objectResponse) {
             if ($library->file_name_014 == $objectResponse['fileName']) {
                 $objectResponse['library'] = $library->id_014;
                 $objectResponse['libraryFileName'] = $library->file_name_014;
             }
         }
     }
     $response = ['success' => true, 'files' => $objectsResponse];
     return response()->json($response);
 }
 public function generate()
 {
     /*GENERATE BASE CONTROLLER FOR NAMESPACE */
     if (!FileSystem::exists($this->path . $this->pathname . '/BaseController.php')) {
         $baseDistPath = realpath(__DIR__ . '/../Controllers/BaseController.php.dist');
         $basePath = realpath(__DIR__ . '/../Controllers/') . '/BaseController.php';
         $copy = FileSystem::copy($baseDistPath, $basePath);
         $base = realpath(__DIR__ . '/../Controllers/BaseController.php');
         $find = 'use App\\Http\\Controllers\\Controller;';
         $replace = 'use ' . $this->getAppNamespace() . 'Http\\Controllers\\Controller;';
         $find2 = 'namespace AppNamespace\\Http\\Controllers\\API;';
         $replace2 = 'namespace ' . $this->getAppNamespace() . 'Http\\Controllers\\' . $this->pathname . ';';
         FileSystem::put($base, str_replace($find2, $replace2, str_replace($find, $replace, file_get_contents($base))));
         if (!FileSystem::isDirectory($this->path . $this->pathname)) {
             FileSystem::makeDirectory($this->path . $this->pathname);
         }
         FileSystem::move($base, $this->path . $this->pathname . '/BaseController.php');
     }
     $prefix = $this->prefix ? $this->prefix . '/' : '';
     $repository = File::make($this->filename)->setLicensePhpdoc(new LicensePhpdoc(self::PROJECT_NAME, self::AUTHOR_NAME, self::AUTHOR_EMAIL))->addFullyQualifiedName(new FullyQualifiedName(\Illuminate\Http\Request::class))->addFullyQualifiedName(new FullyQualifiedName($this->namespace . "BaseController"))->addFullyQualifiedName(new FullyQualifiedName($this->appNamespace . "Repositories\\" . $this->entity . "Repository as Repository"))->addFullyQualifiedName(new FullyQualifiedName($this->appNamespace . "Managers\\" . $this->entity . "Manager as Manager"))->setStructure(Object::make($this->namespace . $this->entity . $this->layer)->extend(new Object(BaseController::class))->addMethod(Method::make('__construct')->addArgument(new Argument('Repository', 'Repository'))->addArgument(new Argument('Manager', 'Manager'))->setBody('        return parent::__construct($Repository , $Manager);'))->addMethod(Method::make('index')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {get} /' . $prefix . snake_case(str_plural($this->entity)) . ' 1 Request all ' . snake_case(str_plural($this->entity)))->addLine('@apiVersion 1.0.0')->addLine('@apiName All' . str_plural($this->entity))->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiSuccess {Object[]}  0 ' . $this->entity . ' Object.')->addLine('@apiSuccess {Number} 0.id Id.')->addLine('@apiSuccess {DateTime} 0.created_at  Created date.')->addLine('@apiSuccess {DateTime} 0.updated_at  Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample Success 200 Example")->addLine(" HTTP/1.1 200 OK")->addLine("[")->addLine("    {")->addLine('        id: 1,')->addLine('        created_at: ' . date('Y-m-d h:i:s') . ',')->addLine('        updated_at: ' . date('Y-m-d h:i:s'))->addLine("    },")->addLine("    {")->addLine('        id: 2,')->addLine('        created_at: ' . date('Y-m-d h:i:s') . ',')->addLine('        updated_at: ' . date('Y-m-d h:i:s'))->addLine("    }")->addLine("]")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->setBody('        return parent::index($Request);'))->addMethod(Method::make('show')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {get} /' . $prefix . snake_case(str_plural($this->entity)) . '/:id 2 Request a specific ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Get' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (Url params) {Number} id ' . $this->entity . ' unique id.')->addEmptyLine()->addLine('@apiSuccess {Number} id Id.')->addLine('@apiSuccess {DateTime} created_at  Created date.')->addLine('@apiSuccess {DateTime} updated_at  Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample {json} Success 200 Example")->addLine(" HTTP/1.1 200 OK")->addLine("{")->addLine('    id: 1,')->addLine('    created_at: ' . date('Y-m-d h:i:s') . ',')->addLine('    updated_at: ' . date('Y-m-d h:i:s'))->addLine("}")->addEmptyLine()->addLine("@apiError (EntityNotFound 404) {string} error The id of the " . snake_case($this->entity) . " was not found.")->addEmptyLine()->addLine("@apiErrorExample {json} EntityNotFound 404 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Entity not found')->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->addArgument(new Argument('integer', 'id'))->setBody('        return parent::show($Request , $id);'))->addMethod(Method::make('store')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {post} /' . $prefix . snake_case(str_plural($this->entity)) . ' 3 Store a  ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Store' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (FormData) {String} name ' . $this->entity . ' name.')->addEmptyLine()->addLine('@apiSuccess (Success 201) {Number} id Id.')->addLine('@apiSuccess (Success 201)  {DateTime} created_at  Created date.')->addLine('@apiSuccess (Success 201)  {DateTime} updated_at  Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample {json} Success 201 Example")->addLine(" HTTP/1.1 201 OK")->addLine("{")->addLine('    id: 1,')->addLine('    created_at: ' . date('Y-m-d h:i:s') . ',')->addLine('    updated_at: ' . date('Y-m-d h:i:s'))->addLine("}")->addEmptyLine()->addLine("@apiError (ValidationErrors 400)  {array[]} name  List of errors for name field.")->addLine("@apiError (ValidationErrors 400)  {string} name.0  First error for name.")->addLine("@apiError (ValidationErrors 400)  {string} name.1  Second error for name.")->addEmptyLine()->addLine("@apiErrorExample {json} ValidationErrors 400 Example")->addLine("  HTTP/1.1 400 Bad Request")->addLine("{")->addLine('    name: [')->addLine('         The name field is required')->addLine("    ]")->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->setBody('        return parent::store($Request);'))->addMethod(Method::make('update')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {put} /' . $prefix . snake_case(str_plural($this->entity)) . '/:id 4 Update a specific  ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Update' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (Url params)  {Number} id ' . $this->entity . ' unique id.')->addLine('@apiParam (FormData) {String} name ' . $this->entity . ' name.')->addEmptyLine()->addLine('@apiSuccess {Number} id Id.')->addLine('@apiSuccess {DateTime} created_at  Created date.')->addLine('@apiSuccess {DateTime} updated_at  Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample {json} Success 200 Example")->addLine(" HTTP/1.1 200 OK")->addLine("{")->addLine('    id: 1,')->addLine('    created_at: ' . date('Y-m-d h:i:s') . ',')->addLine('    updated_at: ' . date('Y-m-d h:i:s'))->addLine("}")->addEmptyLine()->addLine("@apiError (EntityNotFound 404) {string} error The id of the " . snake_case($this->entity) . " was not found.")->addEmptyLine()->addLine("@apiErrorExample {json} EntityNotFound 404 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Entity not found')->addLine("}")->addEmptyLine()->addLine("@apiError (ValidationErrors 400)  {array[]} name  List of errors for name field.")->addLine("@apiError (ValidationErrors 400)  {string} name.0  First error for name.")->addLine("@apiError (ValidationErrors 400)  {string} name.1  Second error for name.")->addEmptyLine()->addLine("@apiErrorExample {json} ValidationErrors 400 Example")->addLine("  HTTP/1.1 400 Bad Request")->addLine("{")->addLine('    name: [')->addLine('         The name field is required')->addLine("    ]")->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->addArgument(new Argument('integer', 'id'))->setBody('        return parent::update($Request , $id);'))->addMethod(Method::make('destroy')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {delete} /' . $prefix . snake_case(str_plural($this->entity)) . '/:id 5 Delete a specific  ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Delete' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (Url params)  {Number} id ' . $this->entity . ' unique id.')->addEmptyLine()->addLine("@apiSuccessExample Success 204 Example")->addLine(" HTTP/1.1 204 OK")->addEmptyLine()->addLine("@apiError (EntityNotFound 404) {string} error The id of the " . snake_case($this->entity) . " was not found.")->addEmptyLine()->addLine("@apiErrorExample {json} EntityNotFound 404 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Entity not found')->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine("  HTTP/1.1 404 Not Found")->addLine("{")->addLine('    error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->addArgument(new Argument('integer', 'id'))->setBody('        return parent::destroy($Request , $id);')));
     $prettyPrinter = Build::prettyPrinter();
     $generatedCode = $prettyPrinter->generateCode($repository);
     return $this->generateFile($generatedCode);
 }
Exemplo n.º 22
0
 /**
  * @param $file
  * @param $projectName
  * @param $path
  */
 public function copyFile($file, $projectName, $path)
 {
     $path = app_path();
     $base = base_path();
     echo $path . '/Util/' . $file . " - " . public_path();
     File::copy($path . '/Util/app.php', '/home/paulo/Projetos/TesteSC/config/app.php');
 }
Exemplo n.º 23
0
 /**
  * @param $src
  * @param $dest
  *
  * @return mixed
  */
 protected function copy($src, $dest)
 {
     return File::copy($this->files[$src], $this->files[$dest]);
 }
Exemplo n.º 24
0
 protected function installAuditTrail()
 {
     $this->makeDirectory(app_path('Http/Controllers/Admin'));
     File::copy($this->stubs('app/Http/Controllers/Admin/AuditTrailController.php'), app_path('Http/Controllers/Admin/AuditTrailController.php'));
     File::copyDirectory($this->stubs('resources/views/admin/auditTrails'), base_path('resources/views/admin/auditTrails'));
 }
 /**
  * Copy the gitignore stub to medialibrary directory.
  * @param string $directory
  */
 private function addIgnoreFileToDirectory($directory)
 {
     $destinationFile = $directory . '/.gitignore';
     if (!file_exists($destinationFile)) {
         File::copy(__DIR__ . '/stubs/gitignore.txt', $destinationFile);
     }
 }
Exemplo n.º 26
0
 /**
  * Copies template type from filepath to target
  *
  * @param  string $type, string $filepath
  * @return void
  */
 protected function copyAndSaveTemplate($type, $filepath)
 {
     $target = $this->viewPathForType($type) . basename($filepath);
     File::copy($filepath, $target);
 }
Exemplo n.º 27
0
 public function insert($file_path, $attributes = [])
 {
     if (!File::exists($file_path)) {
         return -1;
     }
     DB::beginTransaction();
     try {
         $extension = File::extension($file_path);
         $filenameWithoutExtension = $this->filenameWithoutExtension();
         $filename = $this->filename($filenameWithoutExtension, $extension);
         $size = File::size($file_path);
         $save_dir = $this->filePath($this->_dir);
         if (!File::exists($save_dir)) {
             File::makeDirectory($save_dir);
         }
         $save_path = $save_dir . '/' . $filename;
         File::copy($file_path, $save_path);
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         return -1;
     }
     return $this->saveData($filename, $extension, $size, $attributes);
 }
 public function uploadContestantImage(Request $request)
 {
     $input = array('ImageBrowse' => $request->file('ImageBrowse'));
     $rules = array('ImageBrowse' => 'required');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return "";
     } else {
         $files = $request->file('ImageBrowse');
         $file_count = count($files);
         // start count how many uploaded
         $uploadcount = 0;
         foreach ($files as $file) {
             $rules = array('file' => 'required|mimes:png,gif,jpeg,jpg');
             //
             $validator = Validator::make(array('file' => $file), $rules);
             if ($validator->passes()) {
                 $admin_galley_path = config('app.contestant_image_galley');
                 $front_galley_path = config('app.contestant_front_image_galley');
                 $destinationPath = $admin_galley_path;
                 $filename = $request->contestant_id . "_" . date("YmdHis") . '_' . $file->getClientOriginalName();
                 $upload_success = $file->move($destinationPath, $filename);
                 $uploadcount++;
                 //Copy to front folder
                 $file_namecp = $admin_galley_path . $filename;
                 $file_namenw = $front_galley_path . $filename;
                 File::copy($file_namecp, $file_namenw);
                 $cg = new ContestantGallery();
                 $cg->contestant_id = $request->contestant_id;
                 $cg->gallery_path = $filename;
                 $cg->created_by = Auth::user()->username;
                 $cg->save();
             }
         }
         if ($uploadcount == $file_count) {
             $view = "";
             $contestant = Contestant::find($request->contestant_id);
             return view('contestants.listimages', compact('contestant'));
         } else {
             return "";
         }
     }
 }
Exemplo n.º 29
0
 /**
  * Execute the Command.
  */
 public function handle()
 {
     // Get all the models
     $modelFiles = File::allFiles(base_path('scaffolder-config/models/'));
     // Start progress bar
     $this->output->progressStart(count($modelFiles));
     // Get app config
     $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json'));
     // Compilers
     $modelCompiler = new ModelCompiler();
     $migrationCompiler = new MigrationCompiler();
     $controllerCompiler = new ControllerCompiler();
     $indexViewCompiler = new IndexViewCompiler();
     $createViewCompiler = new CreateViewCompiler();
     $editViewCompiler = new EditViewCompiler();
     $pageLayoutViewCompiler = new PageLayoutCompiler();
     $routeCompiler = new RouteCompiler();
     // Compiler output
     $modelCompilerOutput = [];
     $controllerCompilerOutput = [];
     $viewCompilerOutput = [];
     $migrationCompilerOutput = [];
     // Sidenav links
     $sidenavLinks = [];
     // Compiled routes
     $compiledRoutes = '';
     // Get stubs
     $modelStub = File::get($this->stubsDirectory . 'Model.php');
     $migrationStub = File::get($this->stubsDirectory . 'Migration.php');
     $controllerStub = File::get($this->stubsDirectory . 'Controller.php');
     $indexViewStub = File::get($this->themeViews->getIndexPath());
     $createViewStub = File::get($this->themeViews->getCreatePath());
     $editViewStub = File::get($this->themeViews->getEditPath());
     $routeStub = File::get($this->stubsDirectory . 'ResourceRoute.php');
     // Create models directory
     Directory::createIfNotExists(app_path('Models'));
     // Iterate over model files
     foreach ($modelFiles as $modelFile) {
         // Get model name
         $modelName = ucwords($modelFile->getBasename('.' . $modelFile->getExtension()));
         // Get model data
         $modelData = Json::decodeFile($modelFile->getRealPath());
         // Create views directory
         Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName)));
         $modelHash = md5_file($modelFile->getRealPath());
         // Compile stubs
         array_push($modelCompilerOutput, $modelCompiler->compile($modelStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($controllerCompilerOutput, $controllerCompiler->compile($controllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($migrationCompilerOutput, $migrationCompiler->compile($migrationStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         $compiledRoutes .= $routeCompiler->compile($routeStub, $modelName, $modelData, $scaffolderConfig, null);
         // Add entity link
         array_push($sidenavLinks, $modelName);
         // Advance progress
         $this->output->progressAdvance();
     }
     // Store compiled routes
     $routeCompiler->compileGroup(File::get($this->stubsDirectory . 'Routes.php'), $compiledRoutes, $scaffolderConfig);
     // Create layouts directory
     Directory::createIfNotExists(base_path('resources/views/layouts'));
     // Store compiled page layout
     array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, ['links' => $sidenavLinks]));
     // Store create layout
     File::copy($this->themeLayouts->getCreatePath(), base_path('resources/views/layouts/create.blade.php'));
     array_push($viewCompilerOutput, base_path('resources/views/layouts/create.blade.php'));
     // Store edit layout
     File::copy($this->themeLayouts->getEditPath(), base_path('resources/views/layouts/edit.blade.php'));
     array_push($viewCompilerOutput, base_path('resources/views/layouts/edit.blade.php'));
     // Store dashboard
     File::copy($this->themeViews->getDashboardPath(), base_path('resources/views/dashboard.blade.php'));
     array_push($viewCompilerOutput, base_path('resources/views/dashboard.blade.php'));
     // Finish progress
     $this->output->progressFinish();
     // Summary
     $this->comment('- Files created');
     $this->comment('- - Views');
     foreach ($viewCompilerOutput as $viewFile) {
         $this->info('- - - ' . $viewFile);
     }
     $this->comment('- - Controllers');
     foreach ($controllerCompilerOutput as $controllerFile) {
         $this->info('- - - ' . $controllerFile);
     }
     $this->comment('- - Migrations');
     foreach ($migrationCompilerOutput as $migrationFile) {
         $this->info('- - - ' . $migrationFile);
     }
     $this->comment('- - Models');
     foreach ($modelCompilerOutput as $modelFile) {
         $this->info('- - - ' . $modelFile);
     }
 }
Exemplo n.º 30
0
 public function storeCustomRecord($parameters)
 {
     if ($this->request->hasFile('attachment')) {
         $filename = Miscellaneous::uploadFiles('attachment', public_path() . '/packages/syscover/octopus/storage/attachment/order');
     } elseif ($this->request->has('attachment')) {
         File::copy(public_path() . '/packages/syscover/octopus/storage/attachment/request/' . $this->request->input('attachment'), public_path() . '/packages/syscover/octopus/storage/attachment/order/' . $this->request->input('attachment'));
         $filename = $this->request->input('attachment');
     }
     $laboratory = Laboratory::builder()->where('favorite_073', true)->get()->first();
     $order = Order::create(['request_id_079' => $this->request->input('request'), 'supervisor_id_079' => $this->request->input('supervisor'), 'customer_id_079' => $this->request->input('customer'), 'shop_id_079' => $this->request->input('shopId'), 'company_id_079' => $this->request->input('company'), 'family_id_079' => $this->request->input('family'), 'brand_id_079' => $this->request->input('brand'), 'product_id_079' => $this->request->input('product'), 'laboratory_id_079' => $laboratory->id_073, 'address_id_079' => $this->request->has('aliasId') ? $this->request->input('aliasId') : null, 'company_name_079' => $this->request->has('companyName') ? $this->request->input('companyName') : null, 'name_079' => $this->request->has('name') ? $this->request->input('name') : null, 'surname_079' => $this->request->has('surname') ? $this->request->input('surname') : null, 'country_id_079' => $this->request->input('country'), 'territorial_area_1_id_079' => $this->request->has('territorialArea1') ? $this->request->input('territorialArea1') : null, 'territorial_area_2_id_079' => $this->request->has('territorialArea2') ? $this->request->input('territorialArea2') : null, 'territorial_area_3_id_079' => $this->request->has('territorialArea3') ? $this->request->input('territorialArea3') : null, 'cp_079' => $this->request->has('cp') ? $this->request->input('cp') : null, 'locality_079' => $this->request->has('locality') ? $this->request->input('locality') : null, 'address_079' => $this->request->has('address') ? $this->request->input('address') : null, 'phone_079' => $this->request->has('phone') ? $this->request->input('phone') : null, 'email_079' => $this->request->has('email') ? $this->request->input('email') : null, 'observations_079' => $this->request->has('observations') ? $this->request->input('observations') : null, 'date_079' => \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('date'))->getTimestamp(), 'date_text_079' => $this->request->input('date'), 'view_width_079' => $this->request->input('viewWidth'), 'view_height_079' => $this->request->input('viewHeight'), 'total_width_079' => $this->request->has('totalWidth') ? $this->request->input('totalWidth') : null, 'total_height_079' => $this->request->has('totalHeight') ? $this->request->input('totalHeight') : null, 'units_079' => $this->request->input('units'), 'expiration_079' => $this->request->has('expiration') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('expiration'))->getTimestamp() : null, 'expiration_text_079' => $this->request->has('expiration') ? $this->request->input('expiration') : null, 'attachment_079' => isset($filename) ? $filename : null, 'comments_079' => $this->request->has('comments') ? $this->request->input('comments') : null]);
     RequestModel::where('id_078', $this->request->input('request'))->update(['order_id_078' => $order->id_079]);
     $this->sendOrderEmail($order->id_079, 'store');
 }