laravel 은 날짜,시간 에 따라 데이터 의 인 스 턴 스 를 조회 합 니 다.

laravel 을 사용 하여 배경 데이터 통 계 를 할 때 매일 등 록 량 과 같은 데 이 터 를 조회 해 야 합 니 다.
이 럴 때 createdat.팀 을 나 누 는 것 은 좋 지 않 습 니 다.
1.그래서 본 고 는 이 조 회 를 어떻게 써 야 합 니까?
2.그리고 한 시간 동안 플러그 인 을 선택 하 는 것 을 추천 합 니 다.통계 에 반드시 사용 되 기 때문에 이번 주 데이터,이 달,이번 분기,지난달...
날짜 별 그룹 데이터:

Event::where('created_at','>',Carbon::parse($request->start_date))
->where('created_at','<',Carbon::parse($request->end_date))
//  where        
->groupBy('date')
->get([DB::raw('DATE(created_at) as date'),DB::raw('COUNT(*) as value')])
->toArray();
조회 한 데 이 터 를 시간 별로 나 누 려 면:

Event::where('created_at','>',Carbon::parse('2017-01-01'))
->where('created_at','<',Carbon::parse('2017-11-09'))
->groupBy('day')
->get([
//  date_format()    created_at  
 DB::raw('DATE_FORMAT(created_at,\'%H\') as day'),
 DB::raw('COUNT(*) as value')])
->toArray()
시간 공유 플러그 인 선택
이것 은홈 페이지 주소
나 는 내 가 고 친 코드 를 동봉 했다.

$(function () {
/*        */
 var start = moment().subtract(30, 'days');
 var end = moment().subtract(-1,'day');
 var datas = {};
/*    ,       input*/
 function cb(start, end) {
  $('#reportrange span').html(start.format('YYYY/MM/DD') + ' - ' + end.format('YYYY/MM/DD'));
 }
 $('#reportrange').daterangepicker({
 startDate: start,
 endDate: end,
 /*     */
 locale: {
  "format": "YYYY/MM/DD",
  "separator": " - ",
  "applyLabel": "  ",
  "cancelLabel": "  ",
  "fromLabel": "From",
  "toLabel": " ",
  "customRangeLabel": "   ",
  "weekLabel": "W",
  "daysOfWeek": ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"
  ],
  "monthNames": ["  ", "  ", "  ", "  ", "  ", "  ", "  ", "  ", "  ", "  ", "   ", "   "
  ],
  "firstDay": 1
 },
 ranges: {
  '  ': [moment(), moment().subtract(-1, 'days')],
  '  ': [moment().subtract(1, 'days'), moment()],
  ' 7 ': [moment().subtract(7, 'days'), moment()],
  ' 30 ': [moment().subtract(30, 'days'), moment()],
  '  ': [moment().startOf('month'), moment().endOf('month').subtract(-1,'day')],
  '  ': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month').subtract(-1,'day')],
  '  ': [moment("2017-09-25"), moment().subtract(-1, 'days')]
 }
}, cb);

 cb(start, end);
});
너무 좋아요.
echart 맵 을 사용 할 때 지도 권한 이 없 기 때문에 바 이 두 지 도 를 불 러 옵 니 다.이 구 덩이 는 따로 댓 글 을 달 아 기록 합 시다.
이상 의 이 laravel 은 날짜,시간 에 따라 데 이 터 를 조회 하 는 인 스 턴 스 는 바로 편집장 이 여러분 에 게 공유 하 는 모든 내용 입 니 다.여러분 께 참고 가 되 고 저희 도 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기