travel/service/app/admin/controller/LogController.php

37 lines
1009 B
PHP
Raw Permalink Normal View History

2024-06-24 11:52:30 +08:00
<?php
namespace app\admin\controller;
use app\model\Admins;
use app\model\Orders;
use app\model\Logs;
use support\Request;
class LogController extends base
{
public function Index(Request $request) {
$admin = $request->get('admin');
$sn = $request->get('sn');
$times = $request->get('times');
$query = Logs::with(['admin','orders'])->order('id', 'desc');
if(!empty($admin)){
$admin_id = Admins::where('username', $admin)->value('id');
$query->where('admin_id', $admin_id ?? 0);
}
if(!empty($sn)) {
$order_id = Orders::where('sn', $sn)->value('id');
$query->where('order_id', $order_id ?? 0);
}
if(!empty($times) && count($times)) {
$query->whereBetween('create_time', [strtotime($times[0]),strtotime($times[1])]);
}
$list = $query->paginate($request->get('limit', 30));
return $this->success($list->append(['action_name']));
}
}