1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Modules\Mini\Controllers;
- use App\Base\BaseController;
- use App\Exports\AdminOrderExport;
- use App\Exports\UserOrderExport;
- use App\Modules\Mini\Services\OrderService;
- use Illuminate\Support\Facades\Auth;
- use Maatwebsite\Excel\Facades\Excel;
- class OrderController extends BaseController
- {
- public function paginate()
- {
- $params = $this->valid([
- "page_size" => "",
- ]);
- $paginate = app(OrderService::class)->paginate(Auth::id(), $params);
- return $this->ok($paginate);
- }
- public function export()
- {
- $name = sprintf('用户订单导出%s.xls', date("YmdHis"));
- Excel::store(new UserOrderExport([
- "user_id" => Auth::id(),
- ]), $name, "public");
- return $this->ok([
- "url" => config("app.url") . "/storage/" . $name,
- ]);
- }
- }
|