本文整理匯總了PHP中app\models\Task::created方法的典型用法代碼示例。如果您正苦於以下問題:PHP Task::created方法的具體用法?PHP Task::created怎麽用?PHP Task::created使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Task
的用法示例。
在下文中一共展示了Task::created方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: hasPreviousDuration
{
$parts = json_decode($this->time_log) ?: [];
$part = $parts[count($parts) - 1];
if (count($part) == 1 || !$part[1]) {
return time() - $part[0];
} else {
return 0;
}
}
public function hasPreviousDuration()
{
$parts = json_decode($this->time_log) ?: [];
return count($parts) && (count($parts[0]) && $parts[0][1]);
}
public function getHours()
{
return round($this->getDuration() / (60 * 60), 2);
}
}
Task::created(function ($task) {
//Activity::createTask($task);
});
Task::updating(function ($task) {
//Activity::updateTask($task);
});
Task::deleting(function ($task) {
//Activity::archiveTask($task);
});
Task::restoring(function ($task) {
//Activity::restoreTask($task);
});
示例2: getHours
public function getHours()
{
return round($this->getDuration() / (60 * 60), 2);
}
/**
* Gets the route to the tasks edit action
*
* @return string
*/
public function getRoute()
{
return "/tasks/{$this->public_id}/edit";
}
public function getName()
{
return '#' . $this->public_id;
}
public function getDisplayName()
{
if ($this->description) {
return mb_strimwidth($this->description, 0, 16, "...");
}
return '#' . $this->public_id;
}
}
Task::created(function ($task) {
event(new TaskWasCreated($task));
});
Task::updated(function ($task) {
event(new TaskWasUpdated($task));
});