From ce2a438f69c14214fb70b0bbfc61ed6d576426eb Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 22 Feb 2022 11:09:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=99=E9=A2=9D=E8=BD=AC?= =?UTF-8?q?=E8=B4=A6=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Filters/DealerWalletLogFilter.php | 17 +++++++++++++++++ .../Controllers/Dealer/WalletController.php | 1 + app/Models/DealerWalletLog.php | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 app/Endpoint/Api/Filters/DealerWalletLogFilter.php diff --git a/app/Endpoint/Api/Filters/DealerWalletLogFilter.php b/app/Endpoint/Api/Filters/DealerWalletLogFilter.php new file mode 100644 index 00000000..269cb2c6 --- /dev/null +++ b/app/Endpoint/Api/Filters/DealerWalletLogFilter.php @@ -0,0 +1,17 @@ +onlyTransfer(); + break; + } + } +} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php index 76f9c43a..2652b765 100644 --- a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php +++ b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php @@ -31,6 +31,7 @@ class WalletController extends Controller { $perPage = PaginatorHelper::resolvePerPage('per_page', 20, 50); return WalletLogResource::collection($request->user()->dealerWalletLogs() + ->filter($request->all()) ->latest('id') ->simplePaginate($perPage)); } diff --git a/app/Models/DealerWalletLog.php b/app/Models/DealerWalletLog.php index 5dfcd610..8dfafef9 100644 --- a/app/Models/DealerWalletLog.php +++ b/app/Models/DealerWalletLog.php @@ -4,10 +4,12 @@ namespace App\Models; use App\Enums\DealerWalletAction; use Dcat\Admin\Traits\HasDateTimeFormatter; +use EloquentFilter\Filterable; use Illuminate\Database\Eloquent\Model; class DealerWalletLog extends Model { + use Filterable; use HasDateTimeFormatter; /** * @var array @@ -36,4 +38,12 @@ class DealerWalletLog extends Model { return $this->belongsTo(User::class); } + + public function scopeOnlyTransfer($query) + { + return $query->whereIn('action', [ + DealerWalletAction::TransferIn, + DealerWalletAction::TransferOut, + ]); + } }