Пример #1
0
 public static function dumpToSql($project = Project::TRAVELOCITY)
 {
     $db = config('database.connections.apples_data_center');
     $name = $project . '_' . date('Y-m-d') . '.sql';
     $path = '/export/cruises/' . $name;
     system('mysqldump -h' . $db['host'] . ' -P' . $db['port'] . ' -u' . $db['username'] . ' -p' . $db['password'] . ' ' . $db['database'] . ' cruises --where="project=\'' . $project . '\'" >' . base_path('public') . $path);
     Export::firstOrCreate(['project' => $project, 'name' => $name, 'path' => $path]);
 }
 public function index()
 {
     $project = $this->validateProject(Input::get('project'));
     $cruiseQuery = $project ? Cruises::whereProject($project) : Cruises::getQuery();
     $exportQuery = $project ? Export::whereProject($project) : Export::getQuery();
     $exports = $exportQuery->orderBy('id', 'desc')->take(self::EXPORT_PAGE_SIZE)->get();
     $avg = $cruiseQuery->select(DB::raw($this->buildSelectSQL()))->first();
     return view('admin.cruise')->with('project', $project)->with('exports', $exports)->with('avg', $avg);
 }