public function files($job) { $find = Filessearch::where('jobid', '=', $job)->get(); $find = $find->toArray(); if (empty($find)) { $filessearch = new Filessearch(); $files = Files::select(array($this->tables['path'] . '.path', $this->tables['filename'] . '.name as filename', 'jobid'))->join($this->tables['filename'], $this->tables['file'] . '.filenameid', '=', $this->tables['filename'] . '.filenameid')->join($this->tables['path'], $this->tables['file'] . '.pathid', '=', $this->tables['path'] . '.pathid')->where('jobid', '=', $job)->remember(10)->get(); // ->where('jobid','=', $job); $files = $files->toArray(); if (!empty($files)) { foreach (array_chunk($files, 1000) as $chunked_files) { $t = Filessearch::insert($chunked_files); } } //$filessearch->getConnection()->insert("INSERT INTO ".($filessearch->getTable())." (path, filename, jobid) ".$files->toSql(), array($job)); } /* Mostra o log do Job */ $logs = Logs::select(array('logtext'))->where('jobid', '=', $job)->get(); $logs2 = ""; foreach ($logs as $log) { $logs2[] = preg_replace("/[\t\n]+/", '</br>', $log->logtext); } ////// $files = Filessearch::select(array('path', 'filename'))->where('jobid', '=', $job)->orderBy('path', 'asc'); $files = $files->get(); //->toArray(); //$files=""; if (empty($files)) { foreach ($files as $file) { $ficheiro[$file->path . $file->name] = ''; } $tree = $this->explodeTree($ficheiro, "/"); $tree = $this->recursion($tree); } else { $tree = ""; } // $menu = $this->recursion($tree); return View::make('files', array('jobid' => $job, 'logs' => implode($logs2), 'menu' => $menu = $tree)); }
public function emails() { $count = Logs::select(\DB::raw('count(id) as total'))->where('ref', config('global.companies.current.id'))->where('activity', 'store')->where('module', 'emails')->where('created_at', '>', Carbon::now()->subDays(30))->count(); return $this->jsonResponse(['data' => $count]); }