/** * Execute the console command. * @return void */ public function fire() { $base_path = base_path(''); $this->info('Dependencies installing begins here! (plugin:install)'); // DEPENDENCIES foreach (['RainLab.Translate', 'Flynsarmy.IdeHelper', 'BnB.ScaffoldTranslation', 'October.Drivers', 'RainLab.GoogleAnalytics', 'Genius.StorageClear'] as $required) { $this->info('Installing: ' . $required); Artisan::call("plugin:install", ['name' => $required]); } $this->info('Dependencies installed!'); // THEME $this->info('Installing: oc-genius-theme'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-theme themes/genius"); Theme::setActiveTheme('genius'); // ELIXIR $this->info('Installing: oc-genius-elixir'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-elixir plugins/genius/elixir"); // FORMS $this->info('Installing: oc-genius-forms'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-forms plugins/genius/forms"); // BACKUP $this->info('Installing: oc-genius-backup'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-backup plugins/genius/backup"); // GOOGLE ANALYTICS $this->info('Initial setup: AnalytcsSettings'); if (!AnalytcsSettings::get('project_name')) { AnalytcsSettings::create(['project_name' => 'API Project', 'client_id' => '979078159189-8afk8nn2las4vk1krbv8t946qfk540up.apps.googleusercontent.com', 'app_email' => '*****@*****.**', 'profile_id' => '112409305', 'tracking_id' => 'UA-29856398-24', 'domain_name' => 'retrans.srv.br'])->gapi_key()->add(File::create(['data' => plugins_path('genius/base/assets/genius-analytics.p12')])); } // EMAIL $this->info('Initial setup: MailSettings'); if (!MailSettings::get('mandrill_secret')) { MailSettings::create(['send_mode' => 'mandrill', 'sender_name' => 'Genius Soluções Web', 'sender_email' => '*****@*****.**', 'mandrill_secret' => 't27R2C15NPnZ8tzBrIIFTA']); } // BRAND $this->info('Initial setup: BrandSettings'); if (!BrandSettings::get('app_init')) { BrandSettings::create(['app_name' => 'Genius Soluções Web', 'app_tagline' => 'powered by Genius', "primary_color_light" => "#e67e22", "primary_color_dark" => "#d35400", "secondary_color_light" => "#34495e", "secondary_color_dark" => "#2b3e50", "custom_css" => "", 'app_init' => true])->logo()->add(File::create(['data' => plugins_path('genius/base/assets/genius-logo.png')])); } // USUARIO BASE $this->info('Initial setup: User'); $user = User::find(1); if (!$user->last_name) { $user->update(['first_name' => 'Genius', 'last_name' => 'Soluções Web', 'login' => 'genius', 'email' => '*****@*****.**', 'password' => 'genius', 'password_confirmation' => 'genius']); $user->avatar()->add(File::create(['data' => plugins_path('genius/base/assets/genius-avatar.jpg')])); } $this->info('Genius.Base is ready to rock!'); $this->info(''); $this->info('For Laravel Elixir setup run: php artisan elixir:init'); }
/** Usage example: {{ product.image | transparencyThumb(180,180, {color: [255,0,0]}) }} * @param File $originalImage * @param $width * @param $height * @param array $opts * @return string */ public function transparencyThumb($originalImage, $width, $height, $opts = []) { if ($originalImage == null) { return null; } $extension = $originalImage->getAttribute('extension'); if ($extension == 'png' || $extension == 'gif') { if (isset($opts['color']) == false) { $opts['color'] = [255, 255, 255]; } $appendix = '_trans_tmp_' . implode('-', $opts['color']) . '.jpg'; $dbDiskName = str_replace('.' . $extension, $appendix, $originalImage->getAttribute('file_name')); $dbAttachmentType = $originalImage->getAttribute('attachment_type') . '::transparency'; $dbFile = File::where('file_name', $dbDiskName)->where('attachment_type', $dbAttachmentType)->first(); if ($dbFile) { return $dbFile->getThumb($width, $height, $opts); } if ($extension == 'png') { $tmpImageData = imagecreatefrompng(base_path() . $originalImage->getPath()); } else { $tmpImageData = imagecreatefromgif(base_path() . $originalImage->getPath()); } $imageWidth = imagesx($tmpImageData); $imageHeight = imagesy($tmpImageData); $backgroundImg = imagecreatetruecolor($imageWidth, $imageHeight); $color = imagecolorallocate($backgroundImg, $opts['color'][0], $opts['color'][1], $opts['color'][2]); imagefill($backgroundImg, 0, 0, $color); imagecopy($backgroundImg, $tmpImageData, 0, 0, 0, 0, $imageWidth, $imageHeight); $tmpImagePath = $originalImage->getTempPath() . '/' . $dbDiskName; imagejpeg($backgroundImg, $tmpImagePath); imagedestroy($backgroundImg); imagedestroy($tmpImageData); //return str_replace(base_path(), '', $tmpImagePath); $file = File::create(['data' => $tmpImagePath, 'attachment_type' => $dbAttachmentType]); return $file->getThumb($width, $height, $opts); } return $originalImage->getThumb($width, $height, $opts); }