當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。