本文整理汇总了PHP中app\models\Task::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::whereIn方法的具体用法?PHP Task::whereIn怎么用?PHP Task::whereIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::whereIn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUpcomingTasks
/**
* Get Upcoming Tasks for given Trade
*/
public function getUpcomingTasks(Request $request, $date)
{
$trade_list = Auth::user()->company->tradeList->pluck('id')->toArray();
$tasks = Task::whereIn('trade_id', $trade_list)->where('upcoming', '1')->where('status', '1')->orderBy('name')->get();
// Upcoming Task Categories
$task_cats = [];
$task_list = [];
foreach ($tasks as $task) {
$array = [];
$array['id'] = $task->id;
$array['name'] = $task->name;
$array['code'] = $task->code;
$array['trade_id'] = $task->trade_id;
$task_cats[] = $array;
$task_list[] = $task->id;
}
// Upcoming Task items
$date_from = Carbon::createFromFormat('Y-m-d H:i:s', $date . ' 00:00:00');
$date_to = Carbon::createFromFormat('Y-m-d H:i:s', $date . ' 00:00:00');
$date_from->addDays(7);
$date_to->addDays(49);
$planner = SitePlanner::select(['id', 'site_id', 'entity_type', 'entity_id', 'task_id', 'from', 'to', 'days'])->where('from', '>=', $date_from->format('Y-m-d'))->where('from', '<=', $date_to->format('Y-m-d'))->whereIn('task_id', $task_list)->orderBy('entity_type', 'desc')->orderBy('from')->get();
$task_plan = [];
foreach ($planner as $plan) {
$task_plan[] = $this->getPlanData($plan);
}
$json = [];
$json[] = $task_cats;
$json[] = $task_plan;
return $json;
}