增加账变日志筛选项
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Admin\Controllers\Account;
|
namespace App\Admin\Controllers\Account;
|
||||||
|
|
||||||
use App\Models\AccountLog;
|
use App\Models\AccountLog;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\AccountRule;
|
||||||
use Encore\Admin\Controllers\AdminController;
|
use Encore\Admin\Controllers\AdminController;
|
||||||
use Encore\Admin\Grid;
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
@@ -13,7 +15,8 @@ class LogController extends AdminController
|
|||||||
|
|
||||||
function grid()
|
function grid()
|
||||||
{
|
{
|
||||||
$grid = new Grid(new AccountLog);
|
$grid = new Grid(new AccountLog);
|
||||||
|
$grid->model()->latest();
|
||||||
$userId = request()->user_id;
|
$userId = request()->user_id;
|
||||||
$grid->model()->when($userId, function ($query, $userId) {
|
$grid->model()->when($userId, function ($query, $userId) {
|
||||||
$query->where('user_id', $userId);
|
$query->where('user_id', $userId);
|
||||||
@@ -24,19 +27,20 @@ class LogController extends AdminController
|
|||||||
|
|
||||||
$grid->filter(function ($filter) {
|
$grid->filter(function ($filter) {
|
||||||
$filter->column(1 / 3, function ($filter) {
|
$filter->column(1 / 3, function ($filter) {
|
||||||
$filter->like('rule.title', '触发规则');
|
$filter->equal('rule_id', '触发规则')->select(AccountRule::pluck('title', 'id'));
|
||||||
$filter->equal('type', '账户类型')->select(config('account.account_type'));
|
$filter->equal('type', '账户类型')->select(config('account.account_type'));
|
||||||
});
|
});
|
||||||
// $filter->column(1 / 3, function ($filter) {
|
$filter->column(1 / 3, function ($filter) {
|
||||||
// $filter->where(function ($query) {
|
$filter->where(function ($query) {
|
||||||
// $query->whereHas('user', function ($query) {
|
$query->whereHas('account', function ($query) {
|
||||||
// $query->whereHas('info', function ($query) {
|
$query->whereHasMorph('accountable', 'App\Models\User', function ($query) {
|
||||||
// $query->where('nickname', 'like', "%{$this->input}%");
|
$query->where('id', $this->input);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// }, '会员姓名');
|
}, '会员账号', 'id')->select(User::whereHas('identity', function ($q) {
|
||||||
// $filter->between('variable', '变量');
|
$q->where('identity_id', 1);
|
||||||
// });
|
})->get()->pluck('info.nickname', 'id'));
|
||||||
|
});
|
||||||
$filter->column(1 / 3, function ($filter) {
|
$filter->column(1 / 3, function ($filter) {
|
||||||
$filter->equal('frozen', '冻结')->select([
|
$filter->equal('frozen', '冻结')->select([
|
||||||
0 => '否',
|
0 => '否',
|
||||||
@@ -46,10 +50,15 @@ class LogController extends AdminController
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// $grid->column('user.username', '会员账号');
|
$grid->column('会员账号')->display(function () {
|
||||||
// $grid->column('user.nickname', '会员姓名');
|
return $this->account->accountable->username;
|
||||||
|
});
|
||||||
|
$grid->column('会员昵称')->display(function () {
|
||||||
|
return $this->account->accountable->info->nickname;
|
||||||
|
});
|
||||||
$grid->column('rule.title', '触发规则');
|
$grid->column('rule.title', '触发规则');
|
||||||
$grid->column('type', '类型')->using(config('account.account_type'));
|
$grid->column('type', '类型')
|
||||||
|
->using(config('account.account_type'));
|
||||||
$grid->column('variable', '变量');
|
$grid->column('variable', '变量');
|
||||||
$grid->column('balance', '余额');
|
$grid->column('balance', '余额');
|
||||||
$grid->column('frozen', '冻结')
|
$grid->column('frozen', '冻结')
|
||||||
|
|||||||
Reference in New Issue
Block a user