本文整理匯總了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'));
}
}