54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid\Exports;
|
|
|
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
|
use Dcat\Admin\Actions\Response;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Dcat\Admin\Traits\HasPermissions;
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ShippingOrder extends RowAction
|
|
{
|
|
public function title()
|
|
{
|
|
if ($this->title) {
|
|
return $this->title;
|
|
}
|
|
return '<i class="feather grid-action-icon icon-download"></i> 导出发货单 ';
|
|
}
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.articles.index');
|
|
}
|
|
|
|
/**
|
|
* Handle the action request.
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function handle(Request $request)
|
|
{
|
|
// return response()->streamDownload(function () {
|
|
// $writer = WriterEntityFactory::createXLSXWriter();
|
|
// $writer->openToBrowser('测试'.date('Ymd'));
|
|
|
|
// $writer->addRow(WriterEntityFactory::createRowFromArray([
|
|
// '订单编号', '商品编号', '商品名称', '数量', '姓名', '电话', '地址', '下单时间', '发货数量', '发货单号',
|
|
// ]));
|
|
// $writer->close();
|
|
// });
|
|
return $this->response()->download(admin_route('orders.export_shipping_orders'));
|
|
}
|
|
}
|