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, + ]); + } }