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


PHP Report::where方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  * GET /reports
  *
  * @return Response
  */
 public function index()
 {
     $reports = Report::orderBy('id', 'DESC')->get();
     echo "<pre>";
     print_r($reports);
     echo "</pre>";
     exit;
     $hoje = Carbon::now()->today();
     $ontem = Carbon::now()->yesterday();
     $anteontem = Carbon::now()->subDays(2);
     $reports->hoje = Report::where('created_at', '>=', $hoje)->orderBy('id', 'DESC')->get();
     $reports->ontem = Report::where('created_at', '=', $ontem)->orderBy('id', 'DESC')->get();
     $reports->anteontem = Report::where('created_at', '=', $anteontem)->orderBy('id', 'DESC')->get();
     $reports->anteriores = Report::where('created_at', '<', Carbon::now()->subDays(2))->orderBy('id', 'DESC')->get();
     if ($reports->hoje) {
         foreach ($reports->hoje as $report) {
             // Get HOUR:MINUTE from CREATED_AT
             $date = Carbon::createFromFormat('Y-m-d H:i:s', $report->created_at);
             $report->date = $date->hour . ':' . $date->minute;
         }
     }
     if ($reports->ontem) {
         foreach ($reports->ontem as $report) {
             // Get HOUR:MINUTE from CREATED_AT
             $date = Carbon::createFromFormat('Y-m-d H:i:s', $report->created_at);
             $report->date = $date->hour . ':' . $date->minute;
         }
     }
     return View::make('reports.index', compact('reports'));
 }
开发者ID:waldenylson,项目名称:alfredapp,代码行数:36,代码来源:ReportsController.php

示例2: getHoursFromReports

 public function getHoursFromReports($departmentId, $userId, $week, $year)
 {
     $hoursWorked = 0;
     $report = Report::where('department_id', '=', $departmentId)->where('user_id', '=', $userId)->where('week', '=', $week)->where('year', '=', $year)->first();
     if ($report) {
         $hoursWorked = $report->hours;
     }
     return round($hoursWorked, 2);
 }
开发者ID:uTosTan,项目名称:codesamples,代码行数:9,代码来源:DashboardController.php

示例3: listActivities

 public function listActivities()
 {
     $c_u_result = User::where(DB::raw('date(created_at)'), Carbon::today())->get();
     $u_u_result = User::where(DB::raw('date(updated_at)'), Carbon::today())->where(DB::raw('date(created_at)'), '<', DB::raw('date(updated_at)'))->get();
     $c_a_result = Agency::where(DB::raw('date(created_at)'), Carbon::today())->get();
     $u_a_result = Agency::where(DB::raw('date(updated_at)'), Carbon::today())->where(DB::raw('date(created_at)'), '<', DB::raw('date(updated_at)'))->get();
     //retrive report activities
     $c_r_result = Report::where(DB::raw('date(Reports.created_at)'), Carbon::today())->where('isDeleted', 0)->leftjoin('ReportStatusType', 'ReportStatusType.reportStatusTypeId', '=', 'Reports.status')->leftjoin('ReportType', 'ReportType.ReportTypeId', '=', 'Reports.ReportType')->lists('reportName', 'reportedBy', 'location', 'reportStatusTypeName', 'reportTypeName', 'Reports.created_at', 'Reports.updated_at');
     $u_r_result = Report::where(DB::raw('date(Reports.updated_at)'), Carbon::today())->where(DB::raw('date(Reports.created_at)'), '<', DB::raw('date(Reports.updated_at)'))->where('isDeleted', 0)->leftjoin('ReportStatusType', 'ReportStatusType.reportStatusTypeId', '=', 'Reports.status')->leftjoin('ReportType', 'ReportType.ReportTypeId', '=', 'Reports.ReportType')->lists('reportName', 'reportedBy', 'location', 'reportStatusTypeName', 'reportTypeName', 'Reports.created_at', 'Reports.updated_at');
     $d_r_result = Report::where(DB::raw('date(Reports.deleted_at)'), Carbon::today())->where('isDeleted', 1)->leftjoin('ReportStatusType', 'ReportStatusType.reportStatusTypeId', '=', 'Reports.status')->leftjoin('ReportType', 'ReportType.ReportTypeId', '=', 'Reports.ReportType')->lists('reportName', 'reportedBy', 'location', 'reportStatusTypeName', 'reportTypeName', 'Reports.created_at', 'Reports.updated_at');
     $result = array('users_created' => $c_u_result, 'users_updated' => $u_u_result, 'agencies_created' => $c_a_result, 'agencies_updated' => $u_a_result, 'reports_created' => $c_r_result, 'reports_updated' => $u_r_result, 'reports_deleted' => $d_r_result);
     return Response::json($result)->setCallback(Input::get('callback'));
 }
开发者ID:andrewchng,项目名称:cSystem,代码行数:13,代码来源:AdminController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $reports = Report::where('user', $id)->get();
     return Response::json($reports, 200);
 }
开发者ID:vishnu-b,项目名称:traffic_minimal,代码行数:11,代码来源:ReportController.php

示例5: update

 /**
  * Update the specified resource in storage.
  * PUT /reports/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     return $reports = Report::where('id', $id)->update(Input::all());
 }
开发者ID:anildukkipatty,项目名称:maurice-tool-laravel,代码行数:11,代码来源:ReportsController.php

示例6: index

 public function index()
 {
     $accidents = Report::where('type', 'Accident')->get();
     return Response::json($accidents, 200);
 }
开发者ID:vishnu-b,项目名称:traffic_minimal,代码行数:5,代码来源:AccidentController.php

示例7: report

 public function report()
 {
     $recordId = Input::get('record');
     $reason = Input::get('reason');
     if (!$reason) {
         Session::flash('error', 'Please enter a report reason!');
         return Redirect::back();
     }
     $count = Report::where('path_record_id', '=', $recordId)->count();
     if ($count > 0) {
         Session::flash('error', 'This path has already been reported');
         return Redirect::back();
     }
     // load record
     $record = PathRecord::findOrFail($recordId);
     if ($record->locked) {
         Session::flash('error', 'You cannot report this directory!');
         return Redirect::back();
     }
     $report = new Report();
     $report->path_record_id = $record->id;
     $report->path = $record->path;
     $report->reason = $reason;
     $user = Auth::user();
     if ($user) {
         $report->user_id = $user->id;
     }
     $report->save();
     Session::flash('success', 'Report submitted');
     return Redirect::back();
 }
开发者ID:qqueue,项目名称:MangaIndex,代码行数:31,代码来源:IndexController.php

示例8: updateStatus

 public function updateStatus()
 {
     $reportID = Input::get('reportID');
     $comment = Input::get('comment');
     $status = Input::get('status');
     $input = Input::all();
     $rules = array('Status' => 'numeric', 'comment' => 'max:255');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         $error_messages = $validator->messages();
         $error_response = array('error' => array('message' => $error_messages->first(), 'type' => 'Exception', 'code' => 425));
         return Response::json($error_response, 425)->setCallback(Input::get('callback'));
     } else {
         $old_record = $this->getReportDetails($reportID)[0];
         Report::where('reportID', $reportID)->update(array('comment' => "{$comment}", 'status' => "{$status}"));
         $new_record = $this->getReportDetails($reportID)[0];
         $this->notify($old_record, $new_record);
         return "Report Updated.";
     }
 }
开发者ID:andrewchng,项目名称:cSystem,代码行数:20,代码来源:ReportController.php

示例9: reports

 public function reports()
 {
     return Report::where('tournaments.id', '=', $this->id)->join('games', 'games.id', '=', 'reports.game')->join('rounds', 'rounds.id', '=', 'games.round')->join('tournaments', 'tournaments.id', '=', 'rounds.tournament');
 }
开发者ID:romainmasc,项目名称:jackmarshall,代码行数:4,代码来源:Tournament.php

示例10: postShow

 public function postShow($path)
 {
     $report = Report::where('path', $path)->first();
     $form_input = Input::all();
     $response = [];
     $cached_fields = [];
     $query = app($report->model);
     if (isset($form_input['grouping'])) {
         $grouping = ReportGrouping::findOrFail($form_input['grouping']);
         if (isset($form_input['sorting'])) {
             $column = ReportSorting::findOrFail($form_input['sorting']);
             $dir = 1;
             if (isset($form_input['sorting_dir'])) {
                 $dir = $form_input['sorting_dir'];
             }
             $query = $query->orderBy($column->name, $dir);
         }
         switch ($grouping->sql_function) {
             case 0:
                 $groups = $query->groupBy($grouping->name)->select($grouping->name)->get();
                 break;
             case 1:
                 $groups = $query->groupBy(DB::raw('year(' . $grouping->name . '), month(' . $grouping->name . ')'))->select(DB::raw('year(' . $grouping->name . ') as "year(' . $grouping->name . ')"'), DB::raw('month(' . $grouping->name . ') as "month(' . $grouping->name . ')"'))->get();
                 break;
             case 2:
                 $groups = $query->groupBy(DB::raw('year(' . $grouping->name . ')'))->select(DB::raw('year(' . $grouping->name . ') as "year(' . $grouping->name . ')"'))->get();
                 break;
         }
     } else {
         $groups = ['nogroup'];
     }
     foreach ($groups as $index => $wheres) {
         $query = app($report->model);
         $eagers = ReportEager::where('report_id', $report->id)->lists('name');
         foreach ($eagers as $eager) {
             $query = $query->with($eager);
         }
         if ($wheres !== 'nogroup') {
             foreach ($wheres->toArray() as $key => $value) {
                 $query = $query->where(DB::raw($key), $value);
             }
         }
         $update_query = function ($query, $field, $configs, $input) {
             switch ($field->type) {
                 case 1:
                     $query = $query->whereIn($configs[1], $input);
                     break;
                 case 2:
                     if ($configs[2] == 'from' && strlen($input) > 0) {
                         $query = $query->where($configs[1], '>=', $input);
                     }
                     if ($configs[2] == 'to' && strlen($input) > 0) {
                         $query = $query->where($configs[1], '<=', $input);
                     }
                     break;
                 case 4:
                 case 5:
                     $query = $query->where($configs[1], $input);
                     break;
                 case 6:
                     if (strlen($input) > 0) {
                         $query = $query->where($configs[1], 'like', '%' . $input . '%');
                     }
                     break;
             }
             return $query;
         };
         foreach ($form_input as $name => $value) {
             if (stristr($name, '|') !== false) {
                 $configs = explode('|', $name);
                 if (!isset($cached_fields[$configs[0]])) {
                     $cached_fields[$configs[0]] = ReportField::findOrFail($configs[0]);
                 }
                 $field = $cached_fields[$configs[0]];
                 if (stristr($field->name, '#') === false) {
                     $query = $update_query($query, $field, $configs, $value);
                 } else {
                     $tables_string = explode('#', $configs[1]);
                     $tables = array_reverse(explode('.', $tables_string[0]));
                     $configs[1] = $tables_string[1];
                     $str = '$table = $query->getModel()->getTable();' . "\r\n" . '$configs[1] = $table . "." . $configs[1];' . "\r\n" . '$update_query($query, $field, $configs, $value);';
                     foreach ($tables as $table) {
                         $str = '$query->whereHas("' . $table . '", function($query) use ($update_query, $field, $configs, $value) {' . "\r\n" . $str . "\r\n" . '});';
                     }
                     $query = eval('return ' . $str);
                 }
             }
         }
         if (isset($form_input['sorting'])) {
             $column = ReportSorting::findOrFail($form_input['sorting']);
             $dir = 1;
             if (isset($form_input['sorting_dir'])) {
                 $dir = $form_input['sorting_dir'];
             }
             $query = $query->orderBy($column->name, $dir);
         }
         if ($query->count() > 0) {
             if (isset($form_input['grouping'])) {
                 $grouping = ReportGrouping::findOrFail($form_input['grouping']);
                 switch ($grouping->sql_function) {
//.........这里部分代码省略.........
开发者ID:k4ml,项目名称:laravel-base,代码行数:101,代码来源:ReportController.php

示例11: postReport

 public function postReport($workorderId)
 {
     $report = array_merge(Input::only('data', 'user_id'), ['workorder_id' => $workorderId]);
     if (Input::get('reportId', false)) {
         return Report::where('id', Input::get('reportId'))->update(Input::only('data'));
     }
     return Report::create($report);
 }
开发者ID:anildukkipatty,项目名称:maurice-tool-laravel,代码行数:8,代码来源:WorkordersController.php


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