Lravel 5导出到csv日期问题?

时间:2017-06-14 07:59:04

标签: php laravel-5

我正在尝试使用laravel流明将数据导出到csv,而对于Ui我正在使用angular2。我有日期字段,类型为datetime。因为我无法从UI导出数据,因此在请求的资源上没有“Access-Control-Allow-Origin”标头时会出错。

这是php代码

public function exportOrderData($request){
    $vm = new ViewModels\Response();
    $orders = $this->model->select('order_number','customer_orders.customer_id', 'firstname', 'lastname', 'order_date','status','total','discount')
    ->leftJoin('client_customers', 'client_customers.customer_id', '=', 'customer_orders.customer_id')
    ->where('customer_orders.client_id',$request->user()->client_id)->get();
    if($orders){
        $vm->data = $orders->toArray();

// $data['order_date']="17-06-2017" => if i hardcore this it wont work
// $data['order_date']="sample" =>if i hardcore like this it will work
    }
    else{
        $vm->errors[] = ['property'=>'export', 'message'=>'Cannot export orders data'];
    }
    return $vm;
}

我怎么能回复日期?

0 个答案:

没有答案