当前位置: 首页>>代码示例>>PHP>>正文


PHP Task::users方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:sazanrjb,项目名称:OfficeManagementSystem,代码行数:51,代码来源:HomeController.php


注:本文中的app\Task::users方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。