protected function importTables() { $this->info('Начало импорта таблиц'); $files = \File::AllFiles($this->tmp_dir . 'sql'); $progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($files)); $progress->setFormat('debug'); $progress->start(); foreach ($files as $file) { /* @var $file SplFileInfo */ $table = $file->getFilename(); $data = (include $file->getRealPath()); try { \DB::table($table)->truncate(); if (is_array($data)) { foreach ($data as $insert) { \DB::table($table)->insert($insert); } } } catch (\Exception $e) { $this->info(''); $this->error('Ошибка синхронизации таблицы: ' . $table); $this->error($e->getMessage()); } $progress->advance(); } $progress->finish(); $this->info(''); $this->info('Таблицы успешно импортированы'); }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ foreach (File::AllFiles(__DIR__ . '/Routes') as $partial) { require $partial->getPathname(); } Route::get('/', function () { //return view('home'); return Redirect::route('recipe.index', array('sortField' => 'date_added', 'sortOrder' => 'desc', 'displayCount' => 30)); });