本文整理汇总了PHP中app\Task::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::whereIn方法的具体用法?PHP Task::whereIn怎么用?PHP Task::whereIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::whereIn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
/** @var Collection $lines */
$lines = Line::where('visible', true)->orderBy('list_order', 'asc')->get();
$lineIds = array_map(function ($line) {
return $line['id'];
}, $lines->all());
$dateStart = new \DateTime('-4 day');
$dateEnd = new \DateTime('+4 day');
$tasks = Task::whereIn('line_id', $lineIds)->whereBetween('date', [$dateStart->format('Y-m-d'), $dateEnd->format('Y-m-d')])->get();
return view('nichirei.index', ['lines' => $lines, 'tasks' => $tasks, 'dateStart' => $dateStart, 'dateEnd' => $dateEnd]);
}
示例2: userTasks
public static function userTasks()
{
$ids = static::current()->pluck('user_id')->unique();
$container = collect();
foreach ($ids as $id) {
$subContainer = collect();
$user = User::find($id);
$subContainer->tasks = Task::whereIn('id', $user->currentTasks())->pluck('slug');
$subContainer->name = $user->name;
$container->push($subContainer);
}
return $container;
}
示例3: todayActivityInProgress
/**
* Retrieves information for volunteer's activity of the day that is in progress.
*
* @param \Illuminate\Http\Request $request
* @return JSON array of status of activity with activity
*/
public function todayActivityInProgress(Request $request)
{
if ($request->get('token') != null) {
// Get Authenticated User
$authenticatedUser = JWTAuth::setToken($request->get('token'))->authenticate();
$id = $authenticatedUser->volunteer_id;
// Retrieve Activties within today
$todayactivities = Activity::whereBetween('datetime_start', [Carbon::now()->startOfDay(), Carbon::now()->endOfDay()])->lists('activity_id');
//echo count($todayactivities);
// Retrieve Related Activties within today related to volunteer
$groupStatus = collect(['pick-up', 'at check-up', 'check-up completed']);
$relatedActivty = Task::whereIn('activity_id', $todayactivities)->where('volunteer_id', $id)->whereIn('status', $groupStatus)->lists('activity_id');
$taskStatus = Task::whereIn('activity_id', $todayactivities)->whereIn('status', $groupStatus)->where('volunteer_id', $id)->value('status');
// Retrieve Activity details
$activityToReturn = Activity::with('departureCentre', 'arrivalCentre')->whereIn('activity_id', $relatedActivty)->first();
return response()->json(compact('activityToReturn', 'taskStatus'));
} else {
$status = ["Missing parameter"];
return response()->json(compact('status'));
}
}