当前位置: 首页>>代码示例>>PHP>>正文


PHP Activity::whereNotIn方法代码示例

本文整理汇总了PHP中app\Activity::whereNotIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::whereNotIn方法的具体用法?PHP Activity::whereNotIn怎么用?PHP Activity::whereNotIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Activity的用法示例。


在下文中一共展示了Activity::whereNotIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id)
 {
     $user = User::findOrFail($id);
     $activities = Activity::whereNotIn('id', $user->activities()->get()->map(function ($item, $key) {
         return $item->id;
     }))->get();
     return view('userActivities', compact('user', 'activities'));
 }
开发者ID:partio-scout,项目名称:kokous_backend,代码行数:13,代码来源:UserActivityController.php

示例2: retrieveFilter

 /**
  * Retrieves the filters for activity search.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return  JSON  array of filtered search with activity IDs
  */
 public function retrieveFilter(Request $request)
 {
     if ($request->get('filter') == null) {
         $status = ["Missing parameter"];
         return response()->json(compact('status'));
     } else {
         $filter = $request->get('filter');
         if ($filter == 'start') {
             if ($request->get('token') != null) {
                 $authenticatedUser = JWTAuth::setToken($request->get('token'))->authenticate();
                 $id = $authenticatedUser->volunteer_id;
                 $limit = $request->get('limit');
                 $approvedActivities = Activity::with('tasks')->whereHas('tasks', function ($query) {
                     $query->where('approval', 'like', 'approved');
                 })->lists('activity_id');
                 $appliedActivities = Task::Where('volunteer_id', '=', $id)->where(function ($query) {
                     $query->where('approval', '=', 'rejected')->orWhere('approval', '=', 'pending');
                 })->lists('activity_id');
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $activityList = Activity::whereNotIn('activity_id', $notApproved)->groupBy('location_from_id')->lists('location_from_id');
                 $toReturn = [];
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $approvedActivities)->whereNotIn('activity_id', $appliedActivities)->whereNotIn('activity_id', $notApproved)->where('location_from_id', $location)->distinct()->lists('activity_id');
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_from" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             } else {
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $activityList = Activity::whereNotIn('activity_id', $notApproved)->groupBy('location_from_id')->lists('location_from_id');
                 $toReturn = [];
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $notApproved)->where('location_from_id', $location)->distinct()->lists('activity_id');
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_from" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             }
         } elseif ($filter == 'end') {
             if ($request->get('token') != null) {
                 $authenticatedUser = JWTAuth::setToken($request->get('token'))->authenticate();
                 $id = $authenticatedUser->volunteer_id;
                 $limit = $request->get('limit');
                 $approvedActivities = Activity::with('tasks')->whereHas('tasks', function ($query) {
                     $query->where('approval', 'like', 'approved');
                 })->lists('activity_id');
                 $appliedActivities = Task::Where('volunteer_id', '=', $id)->where(function ($query) {
                     $query->where('approval', '=', 'rejected')->orWhere('approval', '=', 'pending');
                 })->lists('activity_id');
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $notcompleted = Task::where('status', '=', 'completed')->distinct()->lists('activity_id');
                 $activityList = Activity::groupBy('location_to_id')->lists('location_to_id');
                 $toReturn = [];
                 $locationNameString = "";
                 $locationIdString = "";
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     //echo $location;
                     $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $approvedActivities)->whereNotIn('activity_id', $appliedActivities)->where('location_to_id', $location)->whereNotIn('activity_id', $notApproved)->distinct()->lists('activity_id');
                     //$stringToTitle = 'location_to';
                     $stringToList = $locationName . ' ' . $locationList;
                     //$locationNameString = $locationNameString . ',' .  $locationName;
                     //$locationIdString = $locationIdString . ',' . $locationList;
                     //$toReturn = array();
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_to" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             } else {
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $notcompleted = Task::where('status', '=', 'completed')->distinct()->lists('activity_id');
                 $activityList = Activity::groupBy('location_to_id')->lists('location_to_id');
                 $toReturn = [];
                 $locationNameString = "";
                 $locationIdString = "";
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     //echo $location;
                     $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->where('location_to_id', $location)->whereNotIn('activity_id', $notApproved)->distinct()->lists('activity_id');
                     //$stringToTitle = 'location_to';
                     $stringToList = $locationName . ' ' . $locationList;
                     //$locationNameString = $locationNameString . ',' .  $locationName;
                     //$locationIdString = $locationIdString . ',' . $locationList;
                     //$toReturn = array();
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_to" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
//.........这里部分代码省略.........
开发者ID:jonnylow,项目名称:CrowdSourcingApplicationWeb,代码行数:101,代码来源:ActivitiesController.php


注:本文中的app\Activity::whereNotIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。