laravel结果数组

时间:2017-07-07 15:32:26

标签: laravel laravel-5 eloquent laravel-eloquent

我有这个雄辩的查询

$data= \App\Logs::select('id', 'created_at') 
    ->get()         
    ->groupBy(function($val) {
        return Carbon::parse($val->created_at)->format('d-M-');
    })->toArray();

然后重新调整了这个

array:2 [▼
  "06-Jul-" => array:1 [▼
    0 => array:2 [▼
      "id" => 1
      "created_at" => "2017-07-06 13:21:15"
    ]
  ]
  "07-Jul-" => array:3 [▼
    0 => array:2 [▼
      "id" => 2
      "created_at" => "2017-07-07 13:43:23"
    ]
    1 => array:2 [▼
      "id" => 3
      "created_at" => "2017-07-07 14:18:36"
    ]
    2 => array:2 [▼
      "id" => 4
      "created_at" => "2017-07-07 14:18:41"
    ]
  ]
]

我希望只返回计数
“06-Jul-”=> “1”
“07-Jul-”=> “3”

我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您可以在----------------------------------------------------------------------- ---- AttributeError Traceback (most recent call last) <ipython-input-3-9ccbc97fd6b8> in <module>() 1 ----> 2 alt.retrieve_data_from_umiami_latlonam('GISS','AQUA', 'ts') AttributeError: 'module' object has no attribute 'retrieve_data_from_umiami_latlonam' 之后使用/ import sys sys.path.append(r'/mymodules') import altdata as alt 代码:

map/transform