本文整理汇总了PHP中Carbon\Carbon::Now方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::Now方法的具体用法?PHP Carbon::Now怎么用?PHP Carbon::Now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::Now方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDelays
function checkDelays()
{
$criteria = new AndStatement();
$field = $this->eventDao->getQStateName();
$criteria->addStatement($field . "=1");
$field = $this->eventDao->getQValid_dateName();
$criteria->addStatement($field . "< NOW()");
$field = $this->eventDao->getQDelayName();
$criteria->addStatement($field . "=0");
$events = $this->eventDao->find($criteria, null);
if (is_null($events) || is_string($events) || count($events) == 0) {
return false;
}
foreach ($events as $event) {
$project = $this->getProject($event->getPid());
if (!is_object($project)) {
$mail = new Mail();
$mail->setTo("just.urbonas@gmail.com");
$mail->setSubject("WorkFlow.lt Klaida nuskaitant projekta | checkDelays");
if (is_string($project)) {
$mail->setText($project);
}
$mail->sendMail();
continue;
}
$stage = $this->getStageById($event->getSid());
if (!is_object($stage)) {
$mail = new Mail();
$mail->setTo("just.urbonas@gmail.com");
$mail->setSubject("WorkFlow.lt Klaida nuskaitant etapa | checkDelays");
if (is_string($stage)) {
$mail->setText($stage);
}
$mail->sendMail();
continue;
}
$client = $this->getClientById($event->getCid());
if (!is_object($client)) {
$mail = new Mail();
$mail->setTo("just.urbonas@gmail.com");
$mail->setSubject("WorkFlow.lt Klaida nuskaitant klienta | checkDelays");
if (is_string($client)) {
$mail->setText($client);
}
//$mail->sendMail();
continue;
}
if (!$client->isActive() || $client->isEnded() || $client->isEnded_eve() || $client->isMoved()) {
continue;
}
$event->setDelays($event->getDelays() + 1);
$event->setDelay(true);
$this->storeEvent($event);
$rss = new Rss($project->getRsskey());
$eventRss = new EventRss();
$eventRss->title = $eventRss->getText("warningTitle", array($project->getName()));
$eventRss->description = $eventRss->getText("warningDescription", array($project->getName(), $stage->getName(), $this->formatClientInfo($client)));
$eventRss->link = addslashes(htmlspecialchars($this->partnerUrl)) . addslashes(htmlspecialchars($project->getCruid()));
$eventRss->pubDate = Carbon::now()->toRssString();
$eventRss->PID = $project->getId();
$eventRss->CID = $client->getId();
$eventRss->SID = $stage->getId();
if (!$rss->addEvent($project, $eventRss)) {
$mail = new Mail();
$mail->setTo("just.urbonas@gmail.com");
$mail->setSubject("WorkFlow.lt Klaida kuriant RSS irasa | checkDelays");
$mail->setText(print_r($eventRss, true));
$mail->sendMail();
}
$eventHistory = new EventHistory();
$eventHistory->setPid($event->getPid());
$eventHistory->setCid($event->getCid());
$eventHistory->setSid($event->getSid());
$eventHistory->setEid($event->getId());
$eventHistory->setR_date(Carbon::Now()->toDateTimeString());
$eventHistory->setDescription("Pradėtas vieluoti etapas");
$eventHistory->setValid_date($event->getValid_date());
$this->storeEventHistory($eventHistory);
}
}
示例2: importAction
function importAction()
{
if (!isset($_POST['client'])) {
$this->setOutPut(array("error" => $this->errorCode['param_not_found']));
return false;
}
$client = json_decode(urldecode($_POST['client']));
//$client = $this->utf8Decode($client1);
//var_dumpas($client['projectKey']);
if (!isset($client->projectKey) || is_null($client->projectKey)) {
$this->setOutPut(array("error" => $this->errorCode['wrong_param']));
return false;
}
$project = $this->getProject($client->projectKey, $client);
if (!is_object($project)) {
return false;
}
if (!isset($client->name) || is_null($client->name)) {
$this->setOutPut(array("error" => $this->errorCode['wrong_param']));
return false;
}
if (!isset($client->email) || is_null($client->email)) {
$this->setOutPut(array("error" => $this->errorCode['wrong_param']));
return false;
}
if (!isset($client->telephone) || is_null($client->telephone)) {
$this->setOutPut(array("error" => $this->errorCode['wrong_param']));
return false;
}
/*if (!isset($client->comment) || is_null($client->comment)){
$this->setOutPut(array("error" => $this->errorCode['wrong_param']));
return false;
}*/
$now = Carbon::Now();
//Kuriam nauja klienta
$newClient = new Client();
$newClient->setPid($project->getId());
$newClient->setName(substr($client->name, 0, 255));
$newClient->setEmail(substr($client->email, 0, 255));
$newClient->setTelephone(substr($client->telephone, 0, 50));
$newClient->setComment(substr($client->comment, 0, 255));
$newClient->setCustomer(substr($client->customer, 0, 255));
$newClient->setActive(true);
$newClient->setPeriodical(false);
$newClient->setPeriodicalid(0);
$newClient->setR_date($now->toDateTimeString());
$newClient->setR_user(977);
$store = $this->storeClient($newClient);
if (!$store) {
$this->setOutPut(array("error" => $this->errorCode['client_not_stored']));
$mail_ob = new Mail();
$mail_ob->setTo("just.urbonas@gmail.com");
$mail_ob->setText(print_r($newClient, true));
$mail_ob->setSubject("WorkFlow.kaizensistema.lt | Nepavyko sukurti importo kliento.");
$mail_ob->sendMail();
return false;
} else {
$eventHistory = new EventHistory();
$eventHistory->setPid($newClient->getPid());
$eventHistory->setCid($newClient->getId());
$eventHistory->setR_date($newClient->getR_date());
$eventHistory->setDescription(!is_null($client->from) ? $client->from : "Sukurtas integracijos metu");
$this->storeEventHistory($eventHistory);
}
$this->setOutPut(array("ok" => "ok"));
}
示例3: findFromLastFourWeeks
public function findFromLastFourWeeks($key, $value)
{
return $this->findWhereDateTimeBetween($key, $value, 'created_at', DateTime::getDaysAgo(Carbon::now()->daysInMonth, Carbon::Now()->endOfDay()));
}
示例4: addEvent
public function addEvent(Project $project, EventRss $event)
{
$fileName = $this->rssDir . $this->pKey . ".rss";
$now = \Carbon\Carbon::Now();
$nowDateTimeStamp = str_replace(":", "", str_replace(" ", "", str_replace("-", "", $now->toDateTimeString())));
if (!$this->checkFileExists($fileName)) {
if (!$this->storeProjectRssFile($project)) {
return false;
}
}
$xml = $this->openRssFile($fileName);
if ($xml === false) {
return false;
}
$item = $xml->channel->addChild('item');
$item->addChild('title', $event->title);
$item->addChild('link', $event->link . $nowDateTimeStamp);
$item->addChild('description', $event->description);
$item->addChild('pubDate', $event->pubDate);
try {
$xml->asXML($fileName);
} catch (Exception $er) {
return false;
}
$rssLog = new Rss_log();
$rssLog->setPid($event->PID);
$rssLog->setCid($event->CID);
$rssLog->setSid($event->SID);
$rssLog->setEid($event->EID);
$rssLog->setTitle($event->title);
$rssLog->setDescription($event->description);
$rssLog->setLink($event->link);
$rssLog->setType("event add");
$rssLog->setR_date(\Carbon\Carbon::Now()->toDateTimeString());
$this->storeRssLog($rssLog);
return true;
}
示例5: actionTakeOff
function actionTakeOff($currentProject)
{
$backUrl = $this->context->getFlowScopeAttr("backUrl");
$eventErrs = array();
$eventID = $this->context->getRequestAttr("id");
$from = $this->context->getRequestAttr("from");
$which = $this->context->getRequestAttr("which");
if (is_null($eventID)) {
$this->context->setRequestScopeAttr("errortxt", "stage.error.notfound");
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
$event = $this->eventDao->get($eventID);
if (is_null($event)) {
$this->context->setRequestScopeAttr("error", "stage.error.notfound");
$this->cancelEditEvent();
return false;
} else {
if (is_string($event)) {
$this->context->setRequestScopeAttr("error", "error.dberror");
$this->context->setRequestScopeAttr("errortxt", $event);
$event = null;
$this->cancelEditEvent();
return false;
}
}
$stage = $this->stageDao->get($event->getSid());
if (is_null($stage)) {
$this->context->setRequestScopeAttr("error", "stage.error.notfound");
$this->cancelEditEvent();
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
} else {
if (is_string($stage)) {
$this->context->setRequestScopeAttr("error", "error.dberror");
$this->context->setRequestScopeAttr("errortxt", $event);
$event = null;
$this->cancelEditEvent();
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
}
$currEventDate = $event->getValid_date();
$currEventDateObj = Carbon::createFromFormat("Y-m-d H:i:s", $currEventDate);
if ($which == "move") {
$newValidDate = $this->countEventTime($stage->getPeriod_type(), $stage->getDelay(), $currEventDateObj);
} else {
$newValidDate = array();
$newValidDate["validateDate"] = $this->context->getRequestAttr("new_date") . " " . $currEventDateObj->toTimeString();
$begDate = new Carbon();
$endDate = Carbon::createFromFormat("Y-m-d H:i:s", $newValidDate["validateDate"]);
$newValidDate["remindeDate"] = $this->countEventReminderTime($begDate, $endDate);
}
$event->setR_date(Carbon::Now()->toDateTimeString());
$event->setValid_date($newValidDate["validateDate"]);
$event->setReminde_date($newValidDate["remindeDate"]);
$event->setMoved($event->getMoved() + 1);
$event->setDelay(false);
$comment = $this->context->getRequestAttr("comment");
$income = $this->context->getRequestAttr("income");
$cost = $this->context->getRequestAttr("cost");
$wasted_time = $this->context->getRequestAttr("wasted_time");
if (empty($income)) {
$income = null;
}
if (empty($cost)) {
$cost = null;
}
if (empty($wasted_time)) {
$wasted_time = null;
}
$eventErrs = array();
if (!is_null($income) && !is_numeric($income)) {
$eventErrs['balanse'] = true;
}
if (!is_null($cost) && !is_numeric($cost)) {
$eventErrs['balanse'] = true;
}
if (!is_null($wasted_time) && !is_numeric($wasted_time)) {
$eventErrs['balanse'] = true;
}
$this->context->setFlashScopeAttr("event", $event);
$this->context->setFlashScopeAttr("eventErrs", $eventErrs);
if (count($eventErrs) >= 1) {
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
/* PELNAS */
//.........这里部分代码省略.........
示例6: moveCopyClient
function moveCopyClient($client, $newProjectId, $action)
{
$newProject = $this->projectDao->get($newProjectId);
if (!is_object($newProject)) {
return false;
}
$project = $this->projectDao->get($client->getPid());
if (!is_object($project)) {
return false;
}
$oldClient = clone $client;
$newClient = clone $client;
$newClient->setId(null);
$newClient->setActive(true);
$newClient->setPid($newProject->getId());
$newClient->setR_date(Carbon::Now()->toDateTimeString());
$store = $this->storeClient($newClient);
if (!$store) {
return false;
}
/*if (!$this->saveFirsEvent($newClient))
return false;
if (!$this->sendNotification($newClient))
return false;*/
if ($action == "move") {
$oldClient->setMoved(true);
$store = $this->storeClient($oldClient);
if (!$store) {
return false;
}
$this->moveClientHistory($oldClient, $newClient);
$eventHistory = new EventHistory();
$eventHistory->setPid($newClient->getPid());
$eventHistory->setCid($newClient->getId());
$eventHistory->setR_date($newClient->getR_date());
$description = ($action == "copy" ? "Nukopijuotas" : "Perkeltas") . ' iš projekto <a href="./action.php?action=startview&appName=projectApp&id=' . $project->getId() . '">' . htmlspecialchars($project->getName()) . "</a>";
$eventHistory->setDescription($description);
$this->storeEventHistory($eventHistory);
$eventHistory = new EventHistory();
$eventHistory->setPid($oldClient->getPid());
$eventHistory->setCid($oldClient->getId());
$eventHistory->setR_date($oldClient->getR_date());
$description = 'Perkeltas į projektą <a href="./action.php?action=startview&appName=projectApp&id=' . $newProject->getId() . '">' . htmlspecialchars($newProject->getName()) . "</a>";
$eventHistory->setDescription($description);
$this->storeEventHistory($eventHistory);
} else {
$this->moveClientHistory($oldClient, $newClient);
$eventHistory = new EventHistory();
$eventHistory->setPid($newClient->getPid());
$eventHistory->setCid($newClient->getId());
$eventHistory->setR_date($newClient->getR_date());
$description = ($action == "copy" ? "Nukopijuotas" : "Perkeltas") . ' iš projekto <a href="./action.php?action=startview&appName=projectApp&id=' . $project->getId() . '">' . htmlspecialchars($project->getName()) . "</a>";
$eventHistory->setDescription($description);
$this->storeEventHistory($eventHistory);
}
return true;
}
示例7: actionAssignPartner
function actionAssignPartner($currentUser)
{
$backUrl = $this->context->getFlowScopeAttr("backUrl");
$projectID = $this->context->getRequestAttr("projectID");
$partnerID = $this->context->getRequestAttr("partnerId");
if (is_null($partnerID)) {
$this->context->setRequestScopeAttr("error", "partner.error.notfound");
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
if (is_null($projectID)) {
$this->context->setRequestScopeAttr("error", "project.error.notfound");
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
$partner = $this->partnerDao->get($partnerID);
if (is_null($partner) || is_string($partner)) {
$this->context->setRequestScopeAttr("error", "partner.error.notfound");
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
$partner->setId(null);
$partner->setPid($projectID);
$partner->setCommission(0);
$partner->setR_date(\Carbon\Carbon::Now()->toDateTimeString());
$partner->setR_user($currentUser->getId());
$this->storePartner($partner);
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
示例8: selectSubjectUpdate
public function selectSubjectUpdate(Requests\SelectSubjectCheck $request)
{
$settings_value = Settings::all();
if ($settings_value[0]->value > Carbon::now() && $settings_value[1]->value < Carbon::now()) {
return view('errors.RegisterInValid');
}
$account_details = RegisterUsers::where('email', Auth::user()->email)->get();
$first_day_data_exist = RegisterSubjects::where('account_id', $account_details[0]->id)->count();
$second_day_data_exist = RegisterSubjects2::where('account_id', $account_details[0]->id)->count();
/* If User Doesn't Select the Subject, the Data Would Not Be Saved */
/* If User Has Filled the Form Before, We Will Update the Previous Data */
/* First Day Registration Data */
if ($first_day_data_exist == 1) {
if ($request->get('reg_subject_1') != 0) {
RegisterSubjects::where('account_id', $account_details[0]->id)->update(['reg_subject_1' => $request->get('reg_subject_1')]);
} else {
RegisterSubjects::where('account_id', $account_details[0]->id)->delete();
}
} else {
if ($first_day_data_exist == 0 && $request->get('reg_subject_1')) {
$input = new RegisterSubjects();
$input->account_id = $account_details[0]->id;
// 'Cause the variable account_id is a array.
$input->reg_subject_1 = $request->get('reg_subject_1');
$input->already_pick_1 = 0;
$input->ps = 'NORMAL';
$input->priority = 0;
$input->reg_time = Carbon::Now();
$input->save();
}
}
/* If User Doesn't Select the Subject, the Data Would Not Be Saved */
/* If User Has Filled the Form Before, We Will Update the Previous Data */
/* Second Day Registration Data */
if ($second_day_data_exist == 1) {
if ($request->get('reg_subject_2') != 0) {
RegisterSubjects2::where('account_id', $account_details[0]->id)->update(['reg_subject_2' => $request->get('reg_subject_2')]);
} else {
RegisterSubjects2::where('account_id', $account_details[0]->id)->delete();
}
} else {
if ($second_day_data_exist == 0 && $request->get('reg_subject_2')) {
$input = new RegisterSubjects2();
$input->account_id = $account_details[0]->id;
// 'Cause the variable account_id is a array.
$input->reg_subject_2 = $request->get('reg_subject_2');
$input->already_pick_2 = 0;
$input->ps = 'NORMAL';
$input->priority = 0;
$input->reg_time = Carbon::Now();
$input->save();
}
}
$user_habits_exist = RegisterHabits::where('account_id', $account_details[0]->id)->count();
if ($user_habits_exist) {
return redirect()->intended('/general');
} else {
return redirect()->intended('/general/select-habits');
}
}