Esempio n. 1
2
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Set directories
     $inputPath = base_path('resources/views');
     $outputPath = storage_path('gettext');
     // Create $outputPath or empty it if already exists
     if (File::isDirectory($outputPath)) {
         File::cleanDirectory($outputPath);
     } else {
         File::makeDirectory($outputPath);
     }
     // Configure BladeCompiler to use our own custom storage subfolder
     $compiler = new BladeCompiler(new Filesystem(), $outputPath);
     $compiled = 0;
     // Get all view files
     $allFiles = File::allFiles($inputPath);
     foreach ($allFiles as $f) {
         // Skip not blade templates
         $file = $f->getPathName();
         if ('.blade.php' !== substr($file, -10)) {
             continue;
         }
         // Compile the view
         $compiler->compile($file);
         $compiled++;
         // Rename to human friendly
         $human = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($f->getRelativePathname(), DIRECTORY_SEPARATOR));
         File::move($outputPath . DIRECTORY_SEPARATOR . sha1($file) . '.php', $outputPath . DIRECTORY_SEPARATOR . $human);
     }
     if ($compiled) {
         $this->info("{$compiled} files compiled.");
     } else {
         $this->error('No .blade.php files found in ' . $inputPath);
     }
 }
Esempio n. 2
1
 /**
  * Проверка файлов на различия, проверяется по размеру файла и наличие файла в ФС
  * @retun array
  */
 public function checkFiles()
 {
     $cachedFiles = Cache::remember(static::CACHE_KEY, Carbon::now()->addHours(6), function () {
         $response = $this->request('https://api.github.com/repos/:rep/git/trees/:branch?recursive=true');
         $response = json_decode($response, true);
         $files = ['new_files' => [], 'diff_files' => [], 'third_party_plugins' => []];
         if (isset($response['tree'])) {
             foreach ($response['tree'] as $row) {
                 $filePath = base_path($row['path']);
                 if (!file_exists($filePath)) {
                     $files['new_files'][] = $this->getFileUrlByPath($row['path']);
                     continue;
                 }
                 $fileSize = filesize($filePath);
                 if (isset($row['size']) and $fileSize != $row['size']) {
                     $diff = $fileSize - $this->countFileLines($filePath) - $row['size'];
                     if ($diff > 1 or $diff < -1) {
                         $files['diff_files'][] = ['diff' => Text::bytes($diff), 'path' => $row['path'], 'url' => $this->buildRemoteUrl('https://raw.githubusercontent.com/:rep/:branch/' . $row['path'])];
                     }
                 }
             }
             return $files;
         }
     });
     return $cachedFiles;
 }
Esempio n. 3
0
 protected static function replaceDbName($setupCommand)
 {
     $contents = file_get_contents(__DIR__ . '/../' . $setupCommand->getStubs() . '/.env.example');
     $contents = str_replace('DB_DATABASE=homestead', 'DB_DATABASE=' . $setupCommand->getRepoName(), $contents);
     file_put_contents(base_path() . '/.env', $contents);
     $setupCommand->info(sprintf("Setup up .env to have settings"));
 }
Esempio n. 4
0
/**
 * implements hook_preprocess_page()
 *
 **/
function odsherredweb_preprocess_page(&$variables)
{
    $current_theme = variable_get('theme_default', 'none');
    // Search form
    $variables['simple_navigation_search'] = module_invoke('search', 'block_view', 'search');
    // Navigation
    $variables['sidebar_borger'] = _bellcom_generate_menu('menu-indhold', 'sidebar');
    $variables['sidebar_erhverv'] = _bellcom_generate_menu('menu-erhverv', 'sidebar');
    $variables['sidebar_politik'] = _bellcom_generate_menu('menu-politik', 'sidebar');
    // Add the site structure term id to the page div
    $node = node_load(arg(1));
    if (is_object($node) && isset($node->field_os2web_spotbox_sitestruct)) {
        $termParents = taxonomy_get_parents($node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid']);
        $termId = 'tid-' . $node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid'];
        $termIdParent = "";
        if (!empty($termParents)) {
            $termIdParent = 'tid-' . key($termParents);
        }
        $variables['attributes_array']['class'] = $termIdParent . ' ' . $termId;
    }
    // Paths
    $variables['path_js'] = base_path() . drupal_get_path('theme', $current_theme) . '/js';
    $variables['path_img'] = base_path() . drupal_get_path('theme', $current_theme) . '/images';
    $variables['path_css'] = base_path() . drupal_get_path('theme', $current_theme) . '/css';
    $variables['path_font'] = base_path() . drupal_get_path('theme', $current_theme) . '/font';
}
 /**
  * Boot the service provider.
  */
 public function boot()
 {
     /*
      * Set the proper configuration separator since
      * retrieving configuration values in packages
      * changed from '::' to '.'
      */
     $this::$packageConfigSeparator = '.';
     /*
      * Set the local inventory laravel version for easy checking
      */
     $this::$laravelVersion = 5;
     /*
      * Load the inventory translations from the inventory lang folder
      */
     $this->loadTranslationsFrom(__DIR__ . '/lang', 'inventory');
     /*
      * Assign the configuration as publishable, and tag it as 'config'
      */
     $this->publishes([__DIR__ . '/config/config.php' => config_path('inventory.php')], 'config');
     /*
      * Assign the migrations as publishable, and tag it as 'migrations'
      */
     $this->publishes([__DIR__ . '/migrations/' => base_path('database/migrations')], 'migrations');
 }
Esempio n. 6
0
 /**
  * Asks the module to handle a GET (Read) request
  *
  * @param $view
  * @param $args
  * @return Response
  */
 protected function handleGet($view, $args)
 {
     $artist = $view;
     if (!isset($artist)) {
         return new Response(array('message' => "The Hive Radio music artist cover API version {$this->VERSION}", 'usage' => "cover/[artist]"), 200);
     } else {
         if (\Cache::has("artist_cover_{$artist}")) {
             return $this->buildImageResponse(\Cache::get("artist_cover_{$artist}"));
         } else {
             $youtube_response = file_get_contents("https://www.googleapis.com/youtube/v3/search?q={$artist}&key=" . \Config::get('icebreath.covers.youtube_api_key') . "&fields=items(id(kind,channelId),snippet(thumbnails(medium)))&part=snippet,id");
             $youtube_json = json_decode($youtube_response, true);
             $items = $youtube_json['items'];
             $youtube_source = null;
             for ($i = 0; $i < sizeof($items); $i++) {
                 if ((string) $items[$i]["id"]["kind"] != "youtube#channel") {
                     continue;
                 } else {
                     $youtube_source = $items[$i]["snippet"]["thumbnails"]["medium"]["url"];
                     break;
                 }
             }
             if (isset($youtube_source) && !empty($youtube_source)) {
                 $data = file_get_contents($youtube_source);
                 $expiresAt = Carbon::now()->addHours(\Config::get('icebreath.covers.cache_time'));
                 \Cache::put("artist_cover_{$artist}", $data, $expiresAt);
                 return $this->buildImageResponse($data);
             }
             return $this->buildImageResponse(\File::get(base_path() . '/' . \Config::get('icebreath.covers.not_found_img')));
         }
     }
 }
Esempio n. 7
0
 public function setUp()
 {
     parent::setUp();
     include_once base_path() . '/tests/fixtures/plugins/database/tester/models/User.php';
     include_once base_path() . '/tests/fixtures/plugins/database/tester/models/Author.php';
     $this->runPluginRefreshCommand('Database.Tester');
 }
Esempio n. 8
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');
 }
Esempio n. 9
0
function assets($name = "assets", $path_url = 0)
{
    if ($path_url) {
        return base_path() . config("path." . $name);
    }
    return asset(config("path." . $name));
}
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Filesystem $files)
 {
     $langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
     $diff = [];
     foreach (ModulesLoader::getRegisteredModules() as $module) {
         if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) {
             continue;
         }
         $locale = $this->input->getOption('locale');
         foreach ($files->directories($module->getLocalePath()) as $localeDir) {
             foreach ($files->allFiles($localeDir) as $localeFile) {
                 $vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename();
                 $vendorFilePath = $langDirectory . $vendorFileDir;
                 if (file_exists($vendorFilePath)) {
                     $localArray = $files->getRequire($localeFile->getRealPath());
                     $vendorArray = $files->getRequire($vendorFilePath);
                     $array = array_keys_exists_recursive($localArray, $vendorArray);
                     $arrayDiff = '';
                     foreach (array_dot($array) as $key => $value) {
                         $arrayDiff .= "{$key}: {$value}\n";
                     }
                     if (empty($arrayDiff)) {
                         continue;
                     }
                     $diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir];
                     $diff[] = new TableSeparator();
                     $diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)];
                     $diff[] = new TableSeparator();
                 }
             }
         }
     }
     $this->table($this->headers, $diff);
 }
 public function setUp()
 {
     parent::setUp();
     $this->modulePath = base_path('modules/Blog');
     $this->finder = $this->app['files'];
     $this->artisan('module:make', ['name' => ['Blog']]);
 }
Esempio n. 12
0
 /**
  * Create a new command instance.
  *
  * @return void
  */
 public function __construct($file = 'forever.js')
 {
     parent::__construct();
     $this->file = $file;
     $this->filePath = base_path($file);
     $this->options = ['-l' => storage_path('logs/forever.log'), '-o' => storage_path('logs/forever.out.log'), '-e' => storage_path('logs/forever.err.log'), '--id' => strtolower(config('app.title')), '--append' => '', '--verbose' => ''];
 }
Esempio n. 13
0
 /**
  * Set the Package Publishing
  * @return  void
  */
 private function setPublishers()
 {
     // views
     $this->publishes([__DIR__ . '/../Views/pages' => base_path('finch/pages')]);
     // assets
     $this->publishes([__DIR__ . '/../Assets' => public_path('campuslane/finch')], 'public');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Paths
     $path_views = __DIR__ . '/../resources/views';
     $path_lang = __DIR__ . '/../resources/lang';
     $path_middleware = __DIR__ . '/Middleware';
     $path_assets = __DIR__ . '/../resources/assets';
     // Publish Paths
     $publish_path_views = base_path('resources/views/nonoesp/writing');
     $publish_path_lang = base_path('resources/lang/nonoesp/writing');
     $publish_path_middleware = base_path('app/Http/Middleware');
     $publish_path_assets = base_path('public/nonoesp/writing');
     $publish_path_config = config_path('writing.php');
     // Publish Stuff
     $this->publishes([$path_views => $publish_path_views], 'views');
     $this->publishes([$path_lang => $publish_path_lang], 'lang');
     //$this->publishes([$path_middleware => $publish_path_middleware,], 'middleware');
     $this->publishes([$path_assets => $publish_path_assets], 'assets');
     $this->publishes([__DIR__ . '/../config/config.php' => $publish_path_config], 'config');
     $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'writing');
     // Views
     if (is_dir($publish_path_views)) {
         $this->loadViewsFrom($publish_path_views, 'writing');
         // Load published views
     } else {
         $this->loadViewsFrom($path_views, 'writing');
     }
     // Translations
     if (is_dir($publish_path_lang)) {
         $this->loadTranslationsFrom($publish_path_lang, 'writing');
         // Load published lang
     } else {
         $this->loadTranslationsFrom($path_lang, 'writing');
     }
 }
Esempio n. 15
0
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->loadViewsFrom(__DIR__ . '/views', 'maven');
     $this->publishes([__DIR__ . '/migrations' => database_path('migrations')], 'migrations');
     $this->loadTranslationsFrom(__DIR__ . 'translations', 'maven');
     $this->publishes([__DIR__ . '/translations' => base_path('resources/lang/vendor/maven')], 'translations');
 }
Esempio n. 16
0
 private function articleCrumbs($category)
 {
     $data = ['homeurl' => ViewHelper::webHost(), 'categoryUrl' => "/article/{$category->name}", 'category' => $category];
     $file = base_path() . '/resources/views/frontend/article/_partial/crumbs.blade.php';
     $view = view()->file($file, $data)->render();
     return ViewHelper::markdownParse($view, ['<crumbs><h4>', '</h4></crumbs>']);
 }
 /**
  * Setup for Google API authorization to retrieve directory data
  */
 function __construct()
 {
     // set config options
     $clientId = Config::get('google.client_id');
     $serviceAccountName = Config::get('google.service_account_name');
     $delegatedAdmin = Config::get('google.admin_email');
     $keyFile = base_path() . Config::get('google.key_file_location');
     $appName = Config::get('google.app_name');
     // array of scopes
     $scopes = array('https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.readonly');
     // Create AssertionCredentails object for use with Google_Client
     $creds = new \Google_Auth_AssertionCredentials($serviceAccountName, $scopes, file_get_contents($keyFile));
     // set admin identity for API requests
     $creds->sub = $delegatedAdmin;
     // Create Google_Client to allow making API calls
     $this->client = new \Google_Client();
     $this->client->setApplicationName($appName);
     $this->client->setClientId($clientId);
     $this->client->setAssertionCredentials($creds);
     if ($this->client->getAuth()->isAccessTokenExpired()) {
         $this->client->getAuth()->refreshTokenWithAssertion($creds);
     }
     Cache::forever('service_token', $this->client->getAccessToken());
     // Set instance of Directory object for making Directory API related calls
     $this->service = new \Google_Service_Directory($this->client);
 }
 /**
  * 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
     // Starting with vendor/package, optionally defined interactively
     if ($this->option('i')) {
         $vendor = $this->ask('What is the vendor name?', $this->argument('vendor'));
         $name = $this->ask('What is the package name?', $this->argument('name'));
         $this->info('The language file will be generated and will be put in all folders at the same time');
         $nameLanguage = $this->ask('What will be the name of the language file?', $this->argument('nameLanguageFile'));
     } else {
         $vendor = $this->argument('vendor');
         $name = $this->argument('name');
         $nameLanguage = $this->argument('nameLanguageFile');
     }
     $namelowercase = strtolower($name);
     //$path = getcwd() . '/packages/';
     $path = base_path('packages/');
     $this->info($path);
     $fullPath = $path . $vendor . '/' . $name;
     $this->info($fullPath);
     $pathResourcesLangFolder = $fullPath . '/src/Resources/Lang';
     $this->info($pathResourcesLangFolder);
     $this->generateController($vendor, $name, $pathResourcesLangFolder, $bar, $nameLanguage);
     $bar->finish();
     $this->info('Controller created successfully!');
     $this->output->newLine(2);
     $bar = null;
 }
 public function findTranslations($path = null)
 {
     $path = $path ?: base_path();
     $keys = array();
     $functions = array('trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans', 'Lang::transChoice', '@lang', '@choice');
     $pattern = "(" . implode('|', $functions) . ")" . "\\(" . "[\\'\"]" . "(" . "[a-zA-Z0-9_-]+" . "([.][^)]+)+" . ")" . "[\\'\"]" . "[\\),]";
     // Close parentheses or new parameter
     // Find all PHP + Twig files in the app folder, except for storage
     $finder = new Finder();
     $finder->in($path)->exclude('storage')->name('*.php')->name('*.twig')->files();
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         // Search the current file for the pattern
         if (preg_match_all("/{$pattern}/siU", $file->getContents(), $matches)) {
             // Get all matches
             foreach ($matches[2] as $key) {
                 $keys[] = $key;
             }
         }
     }
     // Remove duplicates
     $keys = array_unique($keys);
     // Add the translations to the database, if not existing.
     foreach ($keys as $key) {
         // Split the group and item
         list($group, $item) = explode('.', $key, 2);
         $this->missingKey('', $group, $item);
     }
     // Return the number of found translations
     return count($keys);
 }
Esempio n. 20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Model::unguard();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // \App\Provinsi::truncate();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // \App\Kabupaten::truncate();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // \App\Kecamatan::truncate();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     \App\Kelurahan::truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     $this->call(ProvinsiPart1Seeder::class);
     $classes = (require base_path() . '/vendor/composer/autoload_classmap.php');
     foreach ($classes as $class) {
         //if(strpos($class, 'Seeder') !== false && strpos($class, 'Kelurahan') == true)
         if (strpos($class, 'Seeder') !== false && strpos($class, 'DatabaseSeeder') != true && strpos($class, 'ProvinsiPart1Seeder') != true) {
             $seederClass = substr(last(explode('/', $class)), 0, -4);
             //var_dump($seederClass);
             $this->call($seederClass);
         }
     }
     //Model::reguard();
 }
Esempio n. 21
0
 /**
  * Add a View instance to the Collector
  *
  * @param \Illuminate\View\View $view
  */
 public function addView(View $view)
 {
     $name = $view->getName();
     $path = $view->getPath();
     if (!is_object($path)) {
         if ($path) {
             $path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
         }
         if (substr($path, -10) == '.blade.php') {
             $type = 'blade';
         } else {
             $type = pathinfo($path, PATHINFO_EXTENSION);
         }
     } else {
         $type = get_class($view);
         $path = '';
     }
     if (!$this->collect_data) {
         $params = array_keys($view->getData());
     } else {
         $data = array();
         foreach ($view->getData() as $key => $value) {
             $data[$key] = $this->exporter->exportValue($value);
         }
         $params = $data;
     }
     $this->templates[] = array('name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type);
 }
Esempio n. 22
0
 public function __construct()
 {
     $this->table = 'gender';
     $this->filename = base_path() . '/app/database/csvs/gender.csv';
     $this->offset_rows = 1;
     $this->mapping = array(0 => 'description');
 }
Esempio n. 23
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $args = $this->argument('watch') == "watch" ? ' watch' : '';
     $args .= $this->option('production') ? ' --production' : '';
     system("gulp --cwd " . base_path() . " --gulpfile=./vendor/darrenmerrett/react-spark/src/gulpfile.js {$args}\n");
     print "\n";
 }
 /**
  * Boot the service provider
  *
  * @return void
  */
 public function boot()
 {
     $this->publishes([__DIR__ . '/assets/config.php' => config_path('rooles.php')], 'config');
     $this->publishes([__DIR__ . '/assets/views/403.blade.php' => base_path('resources/views/errors/403.blade.php')], 'views');
     $this->publishes([__DIR__ . '/assets/migration.php' => database_path('migrations/' . date('Y_m_d_His_') . 'add_role_column_to_user_table.php')], 'migrations');
     $this->mergeConfigFrom(__DIR__ . '/assets/config.php', 'rooles');
 }
 /**
  * Register package's namespaces.
  */
 protected function registerNamespaces()
 {
     $this->mergeConfigFrom(__DIR__ . '/src/config/config.php', 'menus');
     $this->loadViewsFrom(__DIR__ . '/src/views', 'menus');
     $this->publishes([__DIR__ . '/src/config/config.php' => config_path('menus.php')], 'config');
     $this->publishes([__DIR__ . '/src/views' => base_path('resources/views/vendor/pingpong/menus')], 'views');
 }
 public function index(Request $request)
 {
     $parameters = $request->route()->parameters();
     $parser = new Parser($parameters);
     $generator = new Generator($request->path());
     if (!isset($parameters['version']) && !isset($parameters['resource']) && !isset($parameters['action'])) {
         $segments = ['index'];
     } else {
         $segments = $parameters;
     }
     $file = base_path('resources/' . config('apidocu.base') . '/' . implode('/', $segments) . '.md');
     if (file_exists($file)) {
         $content = file_get_contents($file);
         $status = 200;
     } else {
         $status = 404;
         switch (config('apidocu.404.type')) {
             case 'text':
                 $content = config('apidocu.404.value');
                 break;
             case 'view':
                 $content = view(config('apidocu.404.value'));
                 break;
             default:
                 $content = '**404 - page not found**';
                 break;
         }
     }
     $content = $parser->parse($content);
     return Response::make(view('apidocu::index')->with(['navigation' => $generator->navigation(), 'breadcrumb' => $generator->breadcrumb(), 'content' => $content]), $status);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function __construct()
 {
     $this->table = 'permission_role';
     $this->csv_delimiter = ';';
     $this->filename = base_path() . '/database/seeds/csv/permission_role.csv';
     $this->mapping = [0 => 'role_id', 1 => 'permission_id'];
 }
Esempio n. 28
0
 public function saveFiles()
 {
     file_put_contents(base_path() . "/database/migrations/" . date("Y_m_d_His") . "_create_table_" . Str::lower($this->plural_name) . "_table.php", $this->migration_template);
     file_put_contents(base_path() . "/database/seeds/" . Str::title($this->plural_name) . "Seeder.php", $this->seed_template);
     if (!file_exists(app_path() . "/Models")) {
         mkdir(app_path() . "/Models");
     }
     file_put_contents(app_path() . "/Models/" . Str::title($this->model_name) . ".php", $this->model_template);
     file_put_contents(app_path() . "/Http/Controllers/" . Str::title($this->plural_name) . "Controller" . ".php", $this->controller_template);
     if (!file_exists(base_path() . "/resources/lang/en")) {
         mkdir(base_path() . "/resources/lang/en");
     }
     if (!file_exists(base_path() . "/resources/lang/es")) {
         mkdir(base_path() . "/resources/lang/es");
     }
     file_put_contents(base_path() . "/resources/lang/en/" . Str::lower($this->plural_name) . ".php", $this->lang_template);
     file_put_contents(base_path() . "/resources/lang/es/" . Str::lower($this->plural_name) . ".php", $this->lang_template);
     file_put_contents(app_path() . "/Http/routes.php", $this->route_template, FILE_APPEND);
     if (!file_exists(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix : ""))) {
         mkdir(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix : ""));
     }
     if (!file_exists(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name))) {
         mkdir(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name));
     }
     file_put_contents(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name) . "/index.blade.php", $this->index_template);
     file_put_contents(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name) . "/new.blade.php", $this->new_template);
     file_put_contents(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name) . "/edit.blade.php", $this->edit_template);
     $src = __DIR__ . "/../layout";
     $dest = base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "");
     shell_exec("cp -r {$src} {$dest}");
 }
Esempio n. 29
-1
 public function folder_contents()
 {
     $directory = Input::get('dir', '');
     $files = array();
     foreach (File::files(public_path($directory)) as $key => $file) {
         $pathinfo = pathinfo($file);
         $dir = str_replace(base_path() . '/public/', '', $pathinfo['dirname']);
         $dir = str_replace(base_path() . '/', '', $dir);
         $filename = $dir . '/' . $pathinfo['filename'] . '.' . $pathinfo['extension'];
         $thumbnail = $dir . '/thumbs/' . $filename;
         if (File::exists($thumbnail)) {
             $files[] = $thumbnail;
         } else {
             $files[] = $filename;
         }
     }
     $dirs = array();
     foreach (File::directories(public_path($directory)) as $dir) {
         if (!str_contains($dir, 'thumbs')) {
             $dir_name = str_replace('\\', '/', $dir);
             $dirs[] = $dir_name;
         }
     }
     $ret = array('files' => $files, 'dirs' => $dirs);
     return Response::json($ret, 200);
 }
Esempio n. 30
-1
 /**
  * Factory - new up the model and set the required properties.
  *
  * @return \Illuminate\Database\Eloquent\Model
  * @throws \Exception
  */
 protected function initialize()
 {
     $model = app()->make($this->model());
     if (!$model instanceof Model) {
         throw new Exception('model() method must return a string name of an Eloquent Model. Or the provided model cannot be instantiable.');
     }
     if (!property_exists($this->model(), 'path')) {
         throw new Exception("{$this->model()} should have a property named 'path'");
     }
     $path = base_path($model::$path);
     if (!File::isDirectory($path)) {
         throw new Exception("Something went wrong with the path property of {$this->model()} model.");
     }
     $this->model = $model;
     $this->path = $path;
     if (!$this->toc) {
         // Todo Expensive job. Should apply cache..
         $this->toc = Cache::remember('lessons.index', 120, function () use($model) {
             $all = glob(base_path($model::$path . DIRECTORY_SEPARATOR . '*.md'));
             $excepts = [];
             if (property_exists($this->model(), 'excepts')) {
                 foreach ($model::$excepts as $except) {
                     $excepts[] = base_path($model::$path . DIRECTORY_SEPARATOR . $except);
                 }
             }
             $files = array_diff($all, $excepts);
             return array_map(function ($file) {
                 return pathinfo($file, PATHINFO_BASENAME);
             }, $files);
         });
     }
     return;
 }