本文整理汇总了PHP中app\Activity::concept方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::concept方法的具体用法?PHP Activity::concept怎么用?PHP Activity::concept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::concept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//register log in DB
$dateBegin = new \DateTime();
$activity = Activity::concept(ConstDb::LOAD_CRL)->first();
if ($activity) {
$activity->date_begin = $dateBegin->format('Y-m-d H:i:s');
$activity->save();
} else {
Activity::create(['concept' => ConstDb::LOAD_CRL, 'date_begin' => $dateBegin->format('Y-m-d H:i:s')]);
}
//end log
$this->info('Begin: ' . date('H:i:s'));
$result = DB::connection('mysql_crl')->select($this->getQuery(true));
$rows = $result[0]->total;
$this->info("Total de filas: {$rows}");
$begin = 0;
$block = 10000;
$countBlock = 1;
$fCsv = storage_path('app/crl.csv');
if (file_exists($fCsv)) {
unlink($fCsv);
}
$fp = fopen($fCsv, 'w');
fputs($fp, "organization, from, year, quarter, month, total \n");
while ($rows > $begin) {
$result = DB::connection('mysql_crl')->select($this->getQuery(false, $begin, $block));
foreach ($result as $key => $value) {
$array = json_decode(json_encode($value), true);
$replace = ["\n", ',', ' '];
$replaceTo = ["", ';', ' '];
foreach ($array as $key => $value) {
$array[$key] = str_replace($replace, $replaceTo, $value);
}
fputs($fp, implode($array, ',') . "\n");
}
$this->info("End block {$countBlock}: " . date('H:i:s'));
$begin += $block;
$countBlock++;
}
fclose($fp);
$this->info('End export CSV: ' . date('H:i:s'));
Schema::drop('crl');
$db = env('MONGO_DATABASE');
$command = "mongoimport -d {$db} -c crl --type csv --file {$fCsv} --headerline";
shell_exec($command);
//register log in DB
$dateEnd = new \DateTime();
$activity = Activity::concept(ConstDb::LOAD_CRL)->first();
if ($activity) {
$activity->date_end = $dateEnd->format('Y-m-d H:i:s');
$activity->save();
} else {
Activity::create(['concept' => ConstDb::LOAD_CRL, 'date_end' => $dateEnd->format('Y-m-d H:i:s')]);
}
//end log
$this->info('End: ' . $dateEnd->format('H:i:s'));
}
示例2: saveLog
public function saveLog($begin, $concept)
{
$date = new \DateTime();
$activity = Activity::concept($concept)->first();
if ($activity) {
if ($begin) {
$activity->date_begin = $date->format('Y-m-d H:i:s');
} else {
$activity->date_end = $date->format('Y-m-d H:i:s');
}
$activity->save();
} else {
if ($begin) {
Activity::create(['concept' => $concept, 'date_begin' => $date->format('Y-m-d H:i:s')]);
} else {
Activity::create(['concept' => $concept, 'date_end' => $date->format('Y-m-d H:i:s')]);
}
}
}
示例3: getLastUpdate
public function getLastUpdate($concept)
{
switch ($concept) {
case 1:
$concept = ConstDb::LOAD_CERT;
break;
case 2:
$concept = ConstDb::LOAD_CERT_VIG;
break;
case 3:
$concept = ConstDb::LOAD_CRL;
break;
case 4:
$concept = ConstDb::LOAD_CERT_OPER;
break;
default:
$concept = ConstDb::LOAD_CERT;
break;
}
$oActivity = Activity::concept($concept)->first(['date_begin']);
$time = strtotime($oActivity->date_begin);
$date = date('d/m/Y H:i', $time);
return response()->json($date);
}