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


PHP Activity::with方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $activity = array();
     $farm[] = Farm::with('plot.plant')->find($request->input('farmID'));
     $i = 0;
     foreach ($farm as $plot) {
         foreach ($plot->plot as $plot) {
             foreach ($plot->plant as $plant) {
                 if (Activity::with('activityType')->where('plant_id', '=', $plant->id)->first() != null) {
                     $tempActivity = Activity::with('activityType', 'plant.plot', 'user')->where('plant_id', '=', $plant->id)->get()->toArray();
                     foreach ($tempActivity as $temp) {
                         $activity[$i] = $temp;
                         $i++;
                     }
                 }
             }
         }
         $i++;
     }
     usort($activity, function ($a, $b) {
         $rdiff = strcmp($b['date'], $a['date']);
         if ($rdiff) {
             return $rdiff;
         }
         return strcmp($b['time'], $a['time']);
     });
     return $activity;
 }
开发者ID:bossgame1234,项目名称:MS4SF,代码行数:33,代码来源:activityController.php

示例2: ajaxRetrieveMainCharts

 /**
  * Get the main chart (left) for the given branch/centre.
  * Responds to requests to GET /stats/getMainCharts
  *
  * @param  \Illuminate\Http\Request  $request
  * @return Response
  */
 public function ajaxRetrieveMainCharts(Request $request)
 {
     $charts = array();
     array_set($charts, 'options.title.display', true);
     array_set($charts, 'options.title.fontFamily', 'Lato');
     array_set($charts, 'options.title.fontSize', 20);
     array_set($charts, 'options.legend.labels.fontFamily', 'Lato');
     array_set($charts, 'options.legend.labels.fontSize', 16);
     $centre = $request->get('centre');
     $centreList = Auth::user()->centres;
     if ($centre == 'all') {
         $labels = $centreList->sortBy('name')->lists('name');
         $datasets = array();
         $activityCount = Activity::with('centre')->withTrashed()->select('centre_id', DB::raw('count(*) as total'))->WhereIn('centre_id', $centreList->lists('centre_id'))->groupBy('centre_id')->get()->sortBy('centre.name')->lists('total')->transform(function ($item) {
             return intval($item);
         });
         array_set($charts, 'type', 'doughnut');
         array_set($charts, 'options.cutoutPercentage', 30);
         array_set($charts, 'options.title.text', 'Total Number of Activities per Centres');
         array_set($charts, 'options.animation.animateScale', true);
         array_set($charts, 'data.labels', $labels);
         array_set($datasets, 'data', $activityCount);
         $backgroundColor = array('#729ece', '#ff9e4a', '#67bf5c', '#ed665d', '#ad8bc9', '#a8786e', '#ed97ca', '#cdcc5d', '#6dccda', '#a2a2a2');
         $hoverBackgroundColor = array('#aec7e8', '#ffbb78', '#98df8a', '#ff9896', '#c5b0d5', '#c49c94', '#f7b6d2', '#dbdb8d', '#9edae5', '#c7c7c7');
         array_set($datasets, 'backgroundColor', $backgroundColor);
         array_set($datasets, 'hoverBackgroundColor', $hoverBackgroundColor);
         array_set($charts, 'data.datasets', array($datasets));
     } else {
         $labels = array(Carbon::now()->subMonth(5)->format('F'), Carbon::now()->subMonth(4)->format('F'), Carbon::now()->subMonth(3)->format('F'), Carbon::now()->subMonth(2)->format('F'), Carbon::now()->subMonth(1)->format('F'), Carbon::now()->format('F'));
         $activityDataset = array('label' => 'Activities completed', 'backgroundColor' => '#729ece', 'borderWidth' => 1, 'hoverBackgroundColor' => '#aec7e8');
         $activityFiveMthAgo = Activity::ofCentre($centre)->completed()->subMonth(5)->get();
         $activityFourMthAgo = Activity::ofCentre($centre)->completed()->subMonth(4)->get();
         $activityThreeMthAgo = Activity::ofCentre($centre)->completed()->subMonth(3)->get();
         $activityTwoMthAgo = Activity::ofCentre($centre)->completed()->subMonth(2)->get();
         $activityOneMthAgo = Activity::ofCentre($centre)->completed()->subMonth(1)->get();
         $activityThisMth = Activity::ofCentre($centre)->completed()->subMonth(0)->get();
         $activityCount = array($activityFiveMthAgo->count(), $activityFourMthAgo->count(), $activityThreeMthAgo->count(), $activityTwoMthAgo->count(), $activityOneMthAgo->count(), $activityThisMth->count());
         array_set($activityDataset, 'data', $activityCount);
         $volunteerDataset = array('label' => 'Unique Volunteers volunteered', 'backgroundColor' => '#ff9e4a', 'borderWidth' => 1, 'hoverBackgroundColor' => '#ffbb78');
         $volunteerFiveMthAgo = array_unique(Activity::ofCentre($centre)->completed()->subMonth(5)->lists('volunteer_id')->toArray());
         $volunteerFourMthAgo = array_unique(Activity::ofCentre($centre)->completed()->subMonth(4)->lists('volunteer_id')->toArray());
         $volunteerThreeMthAgo = array_unique(Activity::ofCentre($centre)->completed()->subMonth(3)->lists('volunteer_id')->toArray());
         $volunteerTwoMthAgo = array_unique(Activity::ofCentre($centre)->completed()->subMonth(2)->lists('volunteer_id')->toArray());
         $volunteerOneMthAgo = array_unique(Activity::ofCentre($centre)->completed()->subMonth(1)->lists('volunteer_id')->toArray());
         $volunteerThisMth = array_unique(Activity::ofCentre($centre)->completed()->subMonth(0)->lists('volunteer_id')->toArray());
         $volunteerCount = array(count($volunteerFiveMthAgo), count($volunteerFourMthAgo), count($volunteerThreeMthAgo), count($volunteerTwoMthAgo), count($volunteerOneMthAgo), count($volunteerThisMth));
         array_set($volunteerDataset, 'data', $volunteerCount);
         array_set($charts, 'type', 'bar');
         array_set($charts, 'options.title.text', 'Records for Past 6 Months');
         $scaleLabel = array('display' => true, 'fontFamily' => 'Lato', 'fontSize' => 16);
         $xTicks = array('fontFamily' => 'Lato', 'fontSize' => 16);
         $yTicks = array('fontFamily' => 'Lato', 'fontSize' => 16, 'maxTicksLimit' => 6, 'min' => 0, 'suggestedMax' => 15);
         array_set($charts, 'options.scales.xAxes', array(['position' => 'top', 'scaleLabel' => $scaleLabel, 'ticks' => $xTicks]));
         array_set($charts, 'options.scales.yAxes', array(['scaleLabel' => $scaleLabel, 'ticks' => $yTicks]));
         array_set($charts, 'data.labels', $labels);
         array_set($charts, 'data.datasets', array($activityDataset, $volunteerDataset));
     }
     return json_encode($charts);
 }
开发者ID:jonnylow,项目名称:CrowdSourcingApplicationWeb,代码行数:66,代码来源:StatsController.php

示例3: index

 public function index(Request $request)
 {
     $activities = Activity::with(['user', 'subject'])->latest();
     $activities = $activities->where('old_value', 'LIKE', '%' . $request->get('filter') . '%');
     $activities = $activities->orwhere('new_value', 'LIKE', '%' . $request->get('filter') . '%');
     $activities = $activities->orWhere('name', 'LIKE', '%' . $request->get('filter') . '%')->paginate(25);
     $activities->setPath('activity');
     return view('activity.index', compact('activities'));
 }
开发者ID:encry2024,项目名称:inv_5_2,代码行数:9,代码来源:ActivityController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $aktiviteetti = Activity::with('comments')->findOrFail($id);
     $actArray = POF::getItem($aktiviteetti->guid);
     return ['title' => array_get($actArray, 'title', 'ei määritetty'), 'guid' => array_get($actArray, 'guid', 'ei määritetty'), 'content' => array_get($actArray, 'content', 'ei määritetty'), 'pakollisuus' => array_get($actArray, 'tags.pakollisuus.name', 'ei määritetty'), 'pakollisuusikoni' => array_get($actArray, 'tags.pakollisuus.0.icon', 'ei määritetty'), 'ryhmakoko' => array_get($actArray, 'tags.ryhmakoko.0.name', 'ei määritetty'), 'logo' => array_get($actArray, 'images.logo.url', 'https://learn.extension.org/assets/avatar_placeholder-4c003c71739be2ed78864bcd49550380.png'), 'main_image' => array_get($actArray, 'images.main_image.url', 'https://secure.bandit.fm/web/img/no-image.png'), 'paikka' => array_get($actArray, 'tags.paikka.0.name', 'ei määritetty'), 'suoritus_kesto' => array_get($actArray, 'tags.suoritus_kesto.name', 'ei määritetty'), 'comments' => $aktiviteetti->comments];
     //             ,
     //            'pakollisuus' => $actArray->tags->pakollisuus->name, 'ryhmakoko' => $actArray->tags->ryhmakoko->name,
     //            'paikka' => $actArray->tags->paikka->name, 'suoritus_kesto' => $actArray->tags->suoritus_kesto->name];
     //return POF::getItemJson(Activity::findOrFail($id)->guid);
 }
开发者ID:partio-scout,项目名称:kokous_backend,代码行数:16,代码来源:ActivityRestController.php

示例5: getEdit

 /**
  * Responds to requests to GET /activities/edit
  */
 public function getEdit($id = null)
 {
     $activity = \App\Activity::with('activities_dow')->find($id);
     $groupModel = new \App\Group();
     $groups_for_dropdown = $groupModel->getGroupsForDropdown();
     # Get all the possible days so we can include them with check
     $days_for_this_activity = [];
     foreach ($activity->activities_dow as $dow) {
         $days_for_this_activity[] = $dow->day_of_week;
     }
     return view('activities.edit')->with(['activity' => $activity, 'groups_for_dropdown' => $groups_for_dropdown, 'days_for_checkbox' => $this->days_for_checkbox, 'days_for_this_activity' => $days_for_this_activity]);
 }
开发者ID:eldaronco,项目名称:p4,代码行数:15,代码来源:ActivityController.php

示例6: awol

 /**
  * Show the AWOLs for activity
  *
  * @param  int  $activityId
  * @return Response
  */
 public function awol($activityId)
 {
     // Select all attendance records which are
     $activity = Activity::with(['attendances' => function ($query) {
         $query->where('recorded_value', 'A')->orderBy('created_at', 'desc');
     }])->where('acty_id', $activityId)->firstOrFail();
     $atts = $activity->attendances;
     $atts->reject(function ($item) {
         // If this att is the ultimate att, then keep it
         return $item->att_id != $this->chainLookupUltimate($item)->att_id;
     });
     return response()->json(['count' => $atts->count(), 'awol' => $atts->toArray()]);
 }
开发者ID:alansfyeung,项目名称:FLARES,代码行数:19,代码来源:AttendanceController.php

示例7: reportDeleted

 public function reportDeleted(Request $request)
 {
     $date_start = $request->month && $request->year ? Carbon::parse('first day of ' . $request->month . ' ' . $request->year) : Carbon::parse('first day of this month');
     $date_end = $request->month && $request->year ? Carbon::parse('last day of ' . $request->month . ' ' . $request->year) : Carbon::parse('last day of this month');
     if ($request->user()->role == 'admin') {
         return Activity::with(['report' => function ($query) {
             $query->withTrashed();
         }])->with('activity_type', 'user')->where('activity_type_id', 3)->whereBetween('created_at', [$date_start, $date_end])->orderBy('created_at', 'desc')->get();
     }
     return Activity::with(['report' => function ($query) {
         $query->withTrashed();
     }])->with('activity_type', 'user')->where('user_id', $request->user()->id)->where('activity_type_id', 3)->whereBetween('created_at', [$date_start, $date_end])->orderBy('created_at', 'desc')->get();
 }
开发者ID:mcoyevans,项目名称:personiv-productivity-quality-report,代码行数:13,代码来源:ActivityController.php

示例8: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $id)
 {
     // detail -- [ high | med | low ]
     $detailLevel = $request->input('detail', 'low');
     try {
         if ($detailLevel == 'high') {
             $activity = Activity::with('attendances')->firstOrFail($id);
         } else {
             $activity = Activity::findOrFail($id);
         }
         return response()->json(['activity' => $activity->toArray()]);
     } catch (\Exception $ex) {
         return response()->json(['error' => ['code' => $ex->getCode(), 'reason' => $ex->getMessage()]], 404);
     }
 }
开发者ID:alansfyeung,项目名称:FLARES,代码行数:21,代码来源:ActivityController.php

示例9: index

 public function index()
 {
     $activities = Activity::with('module')->get();
     $module = Module::with('activities')->get();
     return View::make("Engagement-Form")->with('module', $module)->with('activities', $activities);
     //$modules=Module::join('activities','activities.module_id','=','modules.id')
     //	->get();
     //return View::make("Engagement-Form")->with('modules', $modules);
     // $modules = DB::table('modules')
     //   		->get();
     //   	$activities = DB::table('activities')
     //    	->join->on('modules', 'activities.module_id', '=', 'modules.id')
     //   		->get();
     //  		return View::make("Engagement-Form")->with('modules', $modules)
     //  			->with('activities', $activities);
     //$activities = Module::with('activities')->find($id)->activities;
     //return View::make("Engagement-Form")->with('activities', $activities);
 }
开发者ID:sreilly1,项目名称:Final-Year-SE-Project,代码行数:18,代码来源:EngagementFormController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Get all activities
     $activities = Activity::with(['user', 'status', 'type', 'lead'])->get();
     return view('activities.index', compact('activities'));
 }
开发者ID:kakapa,项目名称:erpbox,代码行数:11,代码来源:ActivitiesController.php

示例11: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return Activity::with('tasklists')->findOrFail($id)->toJson();
 }
开发者ID:sax69sax,项目名称:task-manager-api,代码行数:10,代码来源:ActivityController.php

示例12: getActivities

 public function getActivities()
 {
     $activities = Activity::with('lesson')->where('user_id', Auth::getAuthIdentifier())->get();
     return $activities;
 }
开发者ID:avminon,项目名称:fels_107,代码行数:5,代码来源:Activity.php

示例13: 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

示例14: 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

示例15: activities

 public function activities()
 {
     $idPageActivities = 38;
     //este id es el id de la pagina en la base de datos en la tabla page con  campo id
     $page = Page::resort($this->resortId)->active()->id($idPageActivities)->with(['contents' => function ($query) {
         $query->where('lang_id', '=', $this->langId);
     }])->first();
     if ($page) {
         $page = $page->contents->first();
         $activities = Activity::with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->where('resort_id', $this->resortId)->get();
         //return dd($page->toArray());
         return View('pages.activities', compact('page', 'activities'));
     }
 }
开发者ID:royalreservations,项目名称:simpsonbay,代码行数:16,代码来源:PagesController.php


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