本文整理汇总了PHP中app\Task::users方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::users方法的具体用法?PHP Task::users怎么用?PHP Task::users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::users方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assigntask
public function assigntask(Requests\TaskRequest $taskRequest)
{
$task = new Task();
$task->task_name = $taskRequest['taskName'];
$task->task_description = $taskRequest['taskDescription'];
$task->assigned_date = date('Y-m-d', strtotime($taskRequest['startingDate']));
$task->completion_date = date('Y-m-d', strtotime($taskRequest['endingDate']));
$taskRange = $this->dateRange->date_range($task->assigned_date, $task->completion_date);
$task->slug = $taskRequest['slug'];
$flag = false;
$empNames = $taskRequest['empName'];
$users = $this->user->where('designation', '=', 'Employee')->get();
// var_dump($empNames);
$var = array();
$leave_user = array();
//for users in leave
$var2 = array();
//for users not in leave
$notLeave = array();
foreach ($empNames as $empName) {
$user = $this->user->find($empName);
$leaves = $user->leaves()->get();
//User That are in Leave
// var_dump($leaves);
if ($leaves->isEmpty()) {
array_push($notLeave, $user);
} else {
array_push($leave_user, $user);
}
}
foreach ($leaves as $leave) {
$start_date = $leave->start_date;
$end_date = $leave->end_date;
$leaveRange = $this->dateRange->date_range($start_date, $end_date);
$flag = $this->dateRange->date_diff_task_leave($taskRange, $leaveRange);
if ($flag) {
array_push($var, $user->id);
break;
}
}
if (empty($var)) {
if ($task->save()) {
$task->users()->attach($empNames);
\Session::flash('notice', 'Task Assigned');
return Redirect::back();
}
} else {
\Session::flash('notice', 'Certain User are Absent');
return Redirect::back()->withInput();
}
}