本文整理匯總了PHP中app\Task::assignee方法的典型用法代碼示例。如果您正苦於以下問題:PHP Task::assignee方法的具體用法?PHP Task::assignee怎麽用?PHP Task::assignee使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Task
的用法示例。
在下文中一共展示了Task::assignee方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetTaskAssignedUser
function testSetTaskAssignedUser()
{
$user = factory(User::class)->create(['name' => "simo"]);
$this->task->assignee()->associate($user);
$this->task->save();
$this->assertEquals('simo', $this->task->assignee->name);
$this->assertEquals(2, $this->task->activity->count());
$this->assertEquals('user_id', $this->task->activity->get(1)->type);
}
示例2: update
/**
* Update the specified task
*
* @param Request $request
* @param Project $project
* @param Task $task
* @return Task
*/
public function update(Request $request, Project $project, Task $task)
{
if (empty($user_id = $request->input('user_id'))) {
$task->assignee()->dissociate();
} else {
$user = \App\User::findOrFail($user_id);
$task->assignee()->associate($user);
}
if (empty($label_id = $request->input('label_id'))) {
$task->label()->dissociate();
} else {
$label = \App\ProjectLabel::findOrFail($label_id);
$task->label()->associate($label);
}
$task->update($request->all());
return $this->show($project, $task);
}