本文整理汇总了PHP中app\Task::whereId方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::whereId方法的具体用法?PHP Task::whereId怎么用?PHP Task::whereId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::whereId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit()
{
$this->_methodName = 'edit';
$this->resolveParams();
if ($this->checkAuth() && !Auth::checkAdmin()) {
throw new \App\Exceptions\ExceptionApiMethodbad($this->_typeName, $this->_methodName, $this->_request_params);
}
$arNeed = ['taskId' => 'required|numeric'];
$this->checkAttr($arNeed);
$this->checkAuth();
$task = \App\Task::whereId($this->_request_params['taskId'])->first();
if (is_null($task)) {
throw new \App\Exceptions\ExceptionApiContactnotfound($this->_request_params, $this->_typeName, $this->_methodName);
}
if (isset($this->_request_params['name'])) {
$arNeed = ['name' => 'required'];
$this->checkAttr($arNeed);
$task->name = trim($this->_request_params['name']);
}
if (isset($this->_request_params['description'])) {
$arNeed = ['description' => 'required'];
$this->checkAttr($arNeed);
$task->description = trim($this->_request_params['description']);
}
if (isset($this->_request_params['score'])) {
$arNeed = ['score' => 'required|numeric'];
$this->checkAttr($arNeed);
$task->point = $this->_request_params['score'];
}
if (isset($this->_request_params['timer'])) {
$arNeed = ['timer' => 'required'];
$this->checkAttr($arNeed);
$task->timer = $this->_request_params['timer'];
}
$task->save();
return $this;
}