检索记录基于其created_at,昨天到当月的开头

时间:2016-05-26 07:07:30

标签: php laravel laravel-5 eloquent php-carbon

我试图根据其创建的'来检索记录。 timestamp列,其中昨天是开始日期,检索记录直到当月开始

 $h_msg1 = m_chat_history::where('employee_id',$request->other_id)->whereNull('to_group')->where('to_employee_id',$request->id)->whereBetween('created_at', [
            Carbon::parse('yesterday')->startOfDay(),
            Carbon::now()->endOfMonth(),
        ])->get();

但不幸的是,它会抛出我的空洞结果,任何帮助,想法,线索,建议,建议吗?

2 个答案:

答案 0 :(得分:0)

尝试以下代码

    $first_day_this_month = date('Y-m-01 H:s:i');
    $yesterDay = date('Y-m-d H:s:i',strtotime("-1 days"));
    $record = m_chat_history::whereBetween('created_at',[$first_day_this_month, $yesterDay])->get();

答案 1 :(得分:0)

根据你的消息,你需要使用 startOfMonth

var zData = createData();
var xData = d3.range(0, zData.length);
var yData = d3.range(0, zData[0].length);

var data = [ {
  z: zData,
  x: xData,
  y: yData,
  type: 'contour',  
  colorscale: 'Jet',
  showscale: false,
  autocontour: false,  
  contours: {
    start: -5,
    end: 3,
    size: 0.5
  }
}];

var layout = {
margin: {
b: 0,
l: 0,
r: 0,
t: 0
},
height: 600,
width: 600,
  title: '',
  xaxis: {
        ticks: '',
      showticklabels: false  

  },
  yaxis: {
       ticks: '',
       showticklabels: false     
  } 
};

Plotly.newPlot('graph', data, layout, {displayModeBar: false});

function createData(){
var data = [
  [
    0.4, 
    0.4, 
    0.7, 
    -1.0, 
    -0.1, 
    0.6, 
    -0.4, 
    0.6, 
    -0.4, 
    1.3, 
    0.7, 
    -0.4, 
    1.1, 
    1.3, 
    0.6, 
    0.1, 
    -0.0, 
    -0.8, 
    -0.8, 
    -1.0
  ], 
  [
    0.4, 
    -0.4, 
    0.4, 
    -1.2, 
    -0.7, 
    0.4, 
    -0.9, 
    0.5, 
    -0.9, 
    1.2, 
    0.5, 
    -1.0, 
    1.3, 
    1.1, 
    0.5, 
    -0.0, 
    -0.1, 
    -1.2, 
    -1.0, 
    -0.9
  ], 
  [
    0.7, 
    0.4, 
    0.1, 
    -1.2, 
    -0.2, 
    0.5, 
    -0.6, 
    0.6, 
    -0.2, 
    0.9, 
    0.6, 
    -0.5, 
    1.1, 
    0.8, 
    0.6, 
    0.1, 
    -0.4, 
    -0.9, 
    -0.7, 
    -0.8
  ], 
  [
    -1.0, 
    -1.2, 
    -1.2, 
    -4.4, 
    -1.9, 
    -0.8, 
    -2.2, 
    -1.0, 
    -2.2, 
    0.0, 
    -0.3, 
    -2.0, 
    -0.2, 
    0.2, 
    -0.8, 
    -1.6, 
    -1.9, 
    -2.4, 
    -2.3, 
    -2.6
  ], 
  [
    -0.1, 
    -0.7, 
    -0.2, 
    -1.9, 
    -2.0, 
    -0.5, 
    -1.9, 
    -0.3, 
    -1.7, 
    0.4, 
    -0.2, 
    -1.9, 
    0.3, 
    0.4, 
    -0.3, 
    -0.8, 
    -0.9, 
    -2.1, 
    -1.8, 
    -2.0
  ], 
  [
    0.6, 
    0.4, 
    0.5, 
    -0.8, 
    -0.5, 
    -0.1, 
    -0.8, 
    0.6, 
    -0.5, 
    1.0, 
    0.5, 
    -0.7, 
    0.8, 
    1.0, 
    0.5, 
    0.1, 
    -0.3, 
    -0.9, 
    -0.7, 
    -1.1
  ], 
  [
    -0.4, 
    -0.9, 
    -0.6, 
    -2.2, 
    -1.9, 
    -0.8, 
    -2.7, 
    -0.6, 
    -2.0, 
    0.3, 
    -0.3, 
    -2.3, 
    -0.0, 
    -0.0, 
    -0.6, 
    -1.1, 
    -1.3, 
    -2.4, 
    -2.0, 
    -2.2
  ], 
  [
    0.6, 
    0.5, 
    0.6, 
    -1.0, 
    -0.3, 
    0.6, 
    -0.6, 
    0.1, 
    -0.8, 
    1.3, 
    0.8, 
    -0.8, 
    1.1, 
    1.3, 
    0.4, 
    0.1, 
    0.1, 
    -0.8, 
    -1.0, 
    -1.0
  ], 
  [
    -0.4, 
    -0.9, 
    -0.2, 
    -2.2, 
    -1.7, 
    -0.5, 
    -2.0, 
    -0.8, 
    -2.9, 
    0.3, 
    -0.4, 
    -2.2, 
    -0.0, 
    -0.0, 
    -0.7, 
    -0.7, 
    -1.3, 
    -2.4, 
    -2.1, 
    -2.6
  ], 
  [
    1.3, 
    1.2, 
    0.9, 
    0.0, 
    0.4, 
    1.0, 
    0.3, 
    1.3, 
    0.3, 
    1.1, 
    1.0, 
    0.2, 
    0.7, 
    1.9, 
    0.9, 
    -0.2, 
    0.3, 
    0.1, 
    -0.4, 
    -0.2
  ], 
  [
    0.7, 
    0.5, 
    0.6, 
    -0.3, 
    -0.2, 
    0.5, 
    -0.3, 
    0.8, 
    -0.4, 
    1.0, 
    0.3, 
    -0.3, 
    1.0, 
    1.1, 
    0.6, 
    0.1, 
    0.3, 
    -0.7, 
    -0.5, 
    -0.6
  ], 
  [
    -0.4, 
    -1.0, 
    -0.5, 
    -2.0, 
    -1.9, 
    -0.7, 
    -2.3, 
    -0.8, 
    -2.2, 
    0.2, 
    -0.3, 
    -2.7, 
    0.0, 
    -0.0, 
    -0.6, 
    -1.0, 
    -1.1, 
    -2.3, 
    -2.1, 
    -2.4
  ], 
  [
    1.1, 
    1.3, 
    1.1, 
    -0.2, 
    0.3, 
    0.8, 
    -0.0, 
    1.1, 
    -0.0, 
    0.7, 
    1.0, 
    0.0, 
    1.6, 
    0.8, 
    1.0, 
    0.8, 
    0.7, 
    -0.2, 
    -0.2, 
    -0.2
  ], 
  [
    1.3, 
    1.1, 
    0.8, 
    0.2, 
    0.4, 
    1.0, 
    -0.0, 
    1.3, 
    -0.0, 
    1.9, 
    1.1, 
    -0.0, 
    0.8, 
    1.2, 
    1.1, 
    0.0, 
    0.2, 
    -0.1, 
    -0.4, 
    0.0
  ], 
  [
    0.6, 
    0.5, 
    0.6, 
    -0.8, 
    -0.3, 
    0.5, 
    -0.6, 
    0.4, 
    -0.7, 
    0.9, 
    0.6, 
    -0.6, 
    1.0, 
    1.1, 
    -0.2, 
    0.1, 
    -0.0, 
    -0.9, 
    -0.6, 
    -1.2
  ], 
  [
    0.1, 
    -0.0, 
    0.1, 
    -1.6, 
    -0.8, 
    0.1, 
    -1.1, 
    0.1, 
    -0.7, 
    -0.2, 
    0.1, 
    -1.0, 
    0.8, 
    0.0, 
    0.1, 
    -0.6, 
    -0.4, 
    -1.2, 
    -1.3, 
    -1.4
  ], 
  [
    -0.0, 
    -0.1, 
    -0.4, 
    -1.9, 
    -0.9, 
    -0.3, 
    -1.3, 
    0.1, 
    -1.3, 
    0.3, 
    0.3, 
    -1.1, 
    0.7, 
    0.2, 
    -0.0, 
    -0.4, 
    -1.3, 
    -1.4, 
    -1.6, 
    -1.9
  ], 
  [
    -0.8, 
    -1.2, 
    -0.9, 
    -2.4, 
    -2.1, 
    -0.9, 
    -2.4, 
    -0.8, 
    -2.4, 
    0.1, 
    -0.7, 
    -2.3, 
    -0.2, 
    -0.1, 
    -0.9, 
    -1.2, 
    -1.4, 
    -3.0, 
    -2.3, 
    -2.5
  ], 
  [
    -0.8, 
    -1.0, 
    -0.7, 
    -2.3, 
    -1.8, 
    -0.7, 
    -2.0, 
    -1.0, 
    -2.1, 
    -0.4, 
    -0.5, 
    -2.1, 
    -0.2, 
    -0.4, 
    -0.6, 
    -1.3, 
    -1.6, 
    -2.3, 
    -2.3, 
    -2.4
  ], 
  [
    -1.0, 
    -0.9, 
    -0.8, 
    -2.6, 
    -2.0, 
    -1.1, 
    -2.2, 
    -1.0, 
    -2.6, 
    -0.2, 
    -0.6, 
    -2.4, 
    -0.2, 
    0.0, 
    -1.2, 
    -1.4, 
    -1.9, 
    -2.5, 
    -2.4, 
    -3.3
  ]
];
return data;
}