本文整理汇总了PHP中app\Activity::whereBetween方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::whereBetween方法的具体用法?PHP Activity::whereBetween怎么用?PHP Activity::whereBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::whereBetween方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: checkActivityApplication
/**
* Handles the checking to prevent user from applying from activities from the same time period of another activity.
*
* @param \Illuminate\Http\Request $request
* @return JSON array with Status
*/
public function checkActivityApplication(Request $request)
{
if ($request->get('volunteer_id') == null || $request->get('activity_id') == null) {
$status = ["Missing parameter"];
return response()->json(compact('status'));
} else {
$userID = $request->get('volunteer_id');
$actID = $request->get('activity_id');
$withdrawnTask = Task::where('volunteer_id', $userID)->where('activity_id', $actID)->where('approval', '=', 'withdrawn')->lists('activity_id');
$applyingActivity = Activity::findOrFail($actID);
if ($applyingActivity == null) {
$status = ["do not exist"];
return response()->json(compact('status'));
} else {
$activityStartTime = $applyingActivity->datetime_start;
$activityDuration = $applyingActivity->expected_duration_minutes;
$activityEndTime = $applyingActivity->datetime_start->addMinutes($activityDuration);
$activityFullDayStart = $applyingActivity->datetime_start->startOfDay()->toDateTimeString();
$activityFullDayEnd = $applyingActivity->datetime_start->endOfDay()->toDateTimeString();
$activitiesOnSameDay = Activity::whereBetween('datetime_start', [$activityFullDayStart, $activityFullDayEnd])->where('activity_id', '<>', $actID)->lists('activity_id');
$status = ['rejected'];
$taskofUserOnSameDay = Task::where('volunteer_id', $userID)->whereIn('activity_id', $activitiesOnSameDay)->whereNotIn('approval', $status)->lists('activity_id');
$check = false;
foreach ($taskofUserOnSameDay as $activityID) {
$activity = Activity::find($activityID);
$bStartTime = $activity->datetime_start;
$bDuration = $activity->expected_duration_minutes;
$bEndTime = $activity->datetime_start->addMinutes($bDuration);
if ($activityStartTime->lte($bStartTime) && $bStartTime->lte($activityEndTime) && $activityEndTime->lte($bEndTime)) {
$check = true;
}
if ($bStartTime->lte($activityStartTime) && $activityStartTime->lte($bEndTime) && $bEndTime->lte($activityEndTime)) {
$check = true;
}
if ($activityStartTime->lte($bStartTime) && $bStartTime->lte($activityEndTime) && $bEndTime->lte($activityEndTime)) {
$check = true;
}
if ($bStartTime->lte($activityStartTime) && $activityStartTime->lte($bEndTime) && $activityEndTime->lte($bEndTime)) {
$check = true;
}
if ($activityStartTime->eq($bStartTime) && $activityEndTime->eq($bEndTime)) {
$check = true;
}
}
if (!$check) {
$status = ["do not exist"];
return response()->json(compact('status'));
} else {
$status = ["exist"];
return response()->json(compact('status'));
}
}
}
}