當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Activity::whereBetween方法代碼示例

本文整理匯總了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'));
     }
 }
開發者ID:jonnylow,項目名稱:CrowdSourcingApplicationWeb,代碼行數:27,代碼來源:VolunteerController.php

示例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'));
             }
         }
     }
 }
開發者ID:jonnylow,項目名稱:CrowdSourcingApplicationWeb,代碼行數:60,代碼來源:ActivitiesController.php


注:本文中的app\Activity::whereBetween方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。