Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param TemplateRequest $request
  * @return Response
  */
 public function store(TemplateRequest $request)
 {
     ini_set('max_execution_time', 0);
     File::delete(base_path('resources/views/Template.php'));
     File::delete(storage_path('tmp/Template.php'));
     File::deleteDirectory(storage_path('tmp/'));
     $file_path = storage_path('tmp/');
     $orginal_name = $request->file('file')->getClientOriginalName();
     if ($request->file('file')->move($file_path, $orginal_name)) {
         Zipper::make($file_path . $orginal_name)->extractTo(storage_path('tmp'));
         $template = (require_once storage_path('tmp/Template.php'));
         $assets = File::move(storage_path('tmp/assets/' . $template['folder']), public_path('assets/' . $template['folder']));
         $template_file = File::move(storage_path('tmp/' . $template['folder']), base_path('resources/views/' . $template['folder']));
         if (!$assets || !$template_file) {
             File::delete(base_path('resources/views/Template.php'));
             File::delete(storage_path('tmp/Template.php'));
             File::deleteDirectory(storage_path('tmp/'));
             Flash::error(trans('whole::http/controllers.templates_flash_1'));
             return redirect()->route('admin.template.index');
         }
         $message = $this->template->create($template) ? ['success', trans('whole::http/controllers.templates_flash_2')] : ['error', trans('whole::http/controllers.templates_flash_3')];
         File::delete(base_path('resources/views/Template.php'));
         File::delete(storage_path('tmp/Template.php'));
         File::deleteDirectory(storage_path('tmp/'));
         Flash::$message[0]($message[1]);
         if ($message[0] == "success") {
             Logs::add('process', trans('whole::http/controllers.templates_log_1', ['name' => $template['name']]));
         } else {
             Logs::add('errors', trans('whole::http/controllers.templates_log_2'));
         }
         return redirect()->route('admin.template.index');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param TemplateRequest $request
  * @return Response
  */
 public function store(TemplateRequest $request)
 {
     ini_set('max_execution_time', 0);
     File::delete(base_path('resources/views/Template.php'));
     File::delete(storage_path('tmp/Template.php'));
     File::deleteDirectory(storage_path('tmp/'));
     $file_path = storage_path('tmp/');
     $orginal_name = $request->file('file')->getClientOriginalName();
     if ($request->file('file')->move($file_path, $orginal_name)) {
         Zipper::make($file_path . $orginal_name)->extractTo(storage_path('tmp'));
         $template = (require_once storage_path('tmp/Template.php'));
         $assets = File::move(storage_path('tmp/assets/' . $template['folder']), public_path('assets/' . $template['folder']));
         $template_file = File::move(storage_path('tmp/' . $template['folder']), base_path('resources/views/' . $template['folder']));
         if (!$assets || !$template_file) {
             File::delete(base_path('resources/views/Template.php'));
             File::delete(storage_path('tmp/Template.php'));
             File::deleteDirectory(storage_path('tmp/'));
             Flash::error('Tema Dosyası Yüklendi ama Dizinler Tasinamadi! Tüm İşlemleriniz İptal Edildi.');
             return redirect()->route('admin.template.index');
         }
         $message = $this->template->create($template) ? ['success', 'Başarıyla Kaydedildi'] : ['error', 'Bir Hata Meydana Geldi ve Kaydedilemedi'];
         File::delete(base_path('resources/views/Template.php'));
         File::delete(storage_path('tmp/Template.php'));
         File::deleteDirectory(storage_path('tmp/'));
         Flash::$message[0]($message[1]);
         if ($message[0] == "success") {
             Logs::add('process', "Şablon Eklendi\n{$template['name']}");
         } else {
             Logs::add('errors', "Şablon Eklenemedi!");
         }
         return redirect()->route('admin.template.index');
     }
 }
 /**
  * @param ComponentRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(ComponentRequest $request)
 {
     Cache::forget('_components');
     ini_set('max_execution_time', 0);
     File::delete(base_path('components/Component.php'));
     File::deleteDirectory(base_path('components/tmp'));
     $file_path = base_path('components/tmp/');
     $orginal_name = $request->file('file')->getClientOriginalName();
     if ($request->file('file')->move($file_path, $orginal_name)) {
         Zipper::make($file_path . $orginal_name)->extractTo(base_path('components'));
         $component = (require_once base_path('components/Component.php'));
         $composer_file_path = base_path('composer.json');
         $composer_file = file($composer_file_path);
         if (isset($component['composer']) && count($component['composer']) > 0) {
             foreach ($composer_file as $line) {
                 $ok = false;
                 if (trim($line) == '"App\\\\": "app/"' || trim($line) == '"App\\\\": "app/",') {
                     if (count($component['composer']) > 0) {
                         foreach ($component['composer'] as $composer) {
                             $lines[] = "            " . $composer . ",\r\n";
                         }
                     }
                     $lines[] = $line;
                     $ok = true;
                 } else {
                     if (!$ok) {
                         $lines[] = $line;
                     }
                 }
             }
             file_put_contents($composer_file_path, $lines);
             unset($lines);
             exec("cd " . base_path() . " && composer update", $sonuc);
             exec("cd " . base_path() . " && composer dump-autoload", $sonuc);
             Logs::add('process', trans('whole::http/controllers.components_log_1'));
         }
         unset($lines);
         $app_file_path = base_path('config/app.php');
         $app_file = file($app_file_path);
         foreach ($app_file as $line) {
             $lines[] = $line;
             if (isset($component['providers']) && count($component['providers']) > 0) {
                 if (trim($line) == "//include components providers") {
                     foreach ($component['providers'] as $provider) {
                         $lines[] = "\t\t" . $provider . ",\n";
                     }
                 }
             }
             if (isset($component['aliases']) && count($component['aliases']) > 0) {
                 if (trim($line) == "//include components aliases") {
                     foreach ($component['aliases'] as $alias) {
                         $lines[] = "\t\t" . $alias . ",\n";
                     }
                 }
             }
         }
         file_put_contents($app_file_path, $lines);
         unset($lines);
         if ($component['vendor']) {
             exec("php " . base_path("artisan") . " vendor:publish", $sonuc);
             exec("cd " . base_path() . " && composer dump-autoload", $sonuc);
         }
         if ($component['migrate']) {
             exec("cd " . base_path() . " && composer dump-autoload", $sonuc);
             exec("php " . base_path("artisan") . " migrate", $sonuc);
             Logs::add('process', trans('whole::http/controllers.components_log_2'));
         }
         if (isset($component['settings']) && count($component['settings']) > 0) {
             $message = $this->component->create($component['settings']) ? ['success', trans('whole::http/controllers.components_flash_1')] : ['error', trans('whole::http/controllers.components_flash_2')];
             if ($message[0] == "success") {
                 Logs::add('process', trans('whole::http/controllers.components_log_3', ['name' => $component['settings']['name']]));
             } else {
                 Logs::add('errors', "Bileşen Eklenemedi");
             }
             Flash::$message[0]($message[1]);
         }
         if (isset($component['sidebar']) && count($component['sidebar']) > 0) {
             $component['sidebar']['top_id'] = isset($component['sidebar']['top_id']) ? $component['sidebar']['top_id'] : "10";
             $component['sidebar']['children_menu'] = isset($component['sidebar']['children_menu']) ? $component['sidebar']['children_menu'] : "0";
             foreach ($component['pages'] as $page) {
                 $this->all_page->saveData('create', ['path' => $page]);
             }
             if ($this->sidebar->saveData('create', $component['sidebar'])) {
                 Logs::add('process', trans('whole::http/controllers.components_log_4', ['name' => $component['settings']['name']]));
             } else {
                 Logs::add('errors', trans('whole::http/controllers.components_log_5', ['name' => $component['settings']['name']]));
             }
         }
         File::delete(base_path('components/Component.php'));
         File::deleteDirectory(base_path('components/tmp'));
         return redirect()->route('admin.component.index');
     }
     Flash::error(trans('whole.http.controllers.components_flash_3'));
     return redirect()->route('admin.component.index');
 }