/** * Get chuck upload path * * @return string */ public function getChunkPath() { $path = public_path('uploads/'); if (!$this->storage->isDirectory($path)) { $this->storage->makeDirectory($path, 0777, true); } return $path; }
/** * Get chuck upload path. * * @return string */ public function getChunkPath() { $path = config('plupload.chunk_path'); if (!$this->storage->isDirectory($path)) { $this->storage->makeDirectory($path, 0777, true); } return $path; }
/** * Execute the console command. * * @return mixed */ public function fire() { $databaseConfig = array(); $environment = $this->ask('What is your current environment? [Default=local] : ', 'local'); $databaseConfig['databaseHost'] = $this->ask('Enter your database host [Default=localhost] : ', 'localhost'); $databaseConfig['databaseName'] = $this->ask('Enter your database name [Default=homestead] : ', 'homestead'); $databaseConfig['databaseUsername'] = $this->ask('Enter your database username [Default=homestead] : ', 'homestead'); $databaseConfig['databasePassword'] = $this->secret('Enter your database password [Default=secret] : ') ?: 'secret'; $databaseConfig['databasePortNumber'] = $this->ask('Enter your database port number [Default=5432] : ', '5432'); $file = new \Illuminate\Filesystem\Filesystem(); $contents = <<<ENV <?php define("LARAVEL_ENV", '{$environment}'); ENV; $file->put(base_path() . '/bootstrap/env.php', $contents); $databaseConfig['environment'] = $environment; $config = View::make('command.runtime-conf', $databaseConfig); if (!$file->isDirectory(base_path() . '/app/config/propel/')) { $file->makeDirectory(base_path() . '/app/config/propel'); } $file->put(base_path() . '/app/config/propel/runtime-conf.xml', $config); $file->put(base_path() . '/app/config/propel/buildtime-conf.xml', $config); exec('vendor/bin/propel config:convert-xml --output-dir="app/config/propel" --input-dir="app/config/propel"'); $dbContent = <<<ENV <?php return array( 'default' => 'pgsql', 'connections' => array( 'pgsql' => array( 'driver' => 'pgsql', 'host' => '{$databaseConfig['databaseHost']}', 'database' => '{$databaseConfig['databaseName']}', 'username' => '{$databaseConfig['databaseUsername']}', 'password' => '{$databaseConfig['databasePassword']}', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ), ), ); ENV; if (!$file->isDirectory(base_path() . '/app/config/' . $environment)) { $file->makeDirectory(base_path() . '/app/config/' . $environment); } $file->put(base_path() . '/app/config/' . $environment . '/database.php', $dbContent); $this->info('You are done.'); }
*/ $app->get('/', function () use($app) { return view('home'); }); $app->get('coupons/generate', function () use($app) { return view('coupons.generate'); }); $app->post('coupons/generate', function (Request $request) use($app) { $title = 'momo@' . time(); $csvFile = $request->file('coupon_codes'); $templateFile = $request->file('coupon_template'); $csv = Reader::createFromPath($csvFile->getRealPath()); $csv->setNewline("\r"); $headers = $csv->fetchOne(); $rows = $csv->setOffset(1)->fetchAll(); $imageManager = new ImageManager(); $filesystem = new \Illuminate\Filesystem\Filesystem(); $filesystem->makeDirectory(storage_path('app/coupons/' . $title), 0777, true); //dd($rows); foreach ($rows as $row) { $code = $row[0]; $template = $imageManager->make($templateFile->getRealPath()); $template->text($code, 620, 310, function ($font) { $font->file(storage_path('app/fonts/Lato-Regular.ttf')); $font->size(24); $font->align('center'); }); $template->save(storage_path('app/coupons/' . $title . '/' . $code . '.' . $templateFile->getClientOriginalExtension())); } echo 'Done'; });
/** * put * * Create a file a file with the specified content * * @param string $path * @param string $content * @param string $directory (optional) * @param bool $createDirIfNotExists (optional) * @return BinaryFile */ public static function put($filename, $content, $directory = self::TMP_FOLDER_NAME, $createDirIfNotExists = true) { $fileSystem = new \Illuminate\Filesystem\Filesystem(); $directory = self::resolvePath($directory); if ($createDirIfNotExists && !$fileSystem->exists($directory)) { $fileSystem->makeDirectory($directory . DIRECTORY_SEPARATOR, 0755, true, true); } $path = $directory . DIRECTORY_SEPARATOR . $filename; $fileSystem->put($path, $content); return new BinaryFile($path); }