WithdrawConfigsController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace App\Http\Controllers\WithdrawConfig;
  3. use App\Http\Controllers\AdminBaseController;
  4. use App\Http\Requests\WithdrawConfigCreateRequest;
  5. use App\Http\Requests\WithdrawConfigUpdateRequest;
  6. use App\Repositories\Eloquent\WithdrawConfigRepositoryEloquent;
  7. use App\Validators\WithdrawConfigValidator;
  8. /**
  9. * Class WithdrawConfigsController.
  10. *
  11. * @package namespace App\Http\Controllers;
  12. */
  13. class WithdrawConfigsController extends AdminBaseController
  14. {
  15. /**
  16. * @var WithdrawConfigRepositoryEloquent
  17. */
  18. protected $repository;
  19. /**
  20. * @var WithdrawConfigValidator
  21. */
  22. protected $validator;
  23. /**
  24. * WithdrawConfigsController constructor.
  25. *
  26. * @param WithdrawConfigRepositoryEloquent $repository
  27. * @param WithdrawConfigValidator $validator
  28. */
  29. public function __construct(WithdrawConfigRepositoryEloquent $repository, WithdrawConfigValidator $validator)
  30. {
  31. parent::__construct($repository, $validator);
  32. }
  33. /**
  34. * 数据检索
  35. */
  36. public function _indexScopeQuery()
  37. {
  38. $where = [];
  39. $search = explode(";", request()->input('search', ""));
  40. $start = $end = null;
  41. $fieldSearchable=$this->repository->getFieldsSearchable();
  42. foreach ($search as $value) {
  43. if (!empty($value)) {
  44. list($one, $tow) = explode(":", $value);
  45. if (!empty($fieldSearchable[$one])) {
  46. if($fieldSearchable[$one]=='like')$tow="%{$tow}%";
  47. $where[]=[$one,$fieldSearchable[$one],$tow];
  48. } elseif ($one == 'start') {
  49. $start = $tow . " 00:00:00";
  50. } elseif ($one == 'end') {
  51. $end = $tow . " 23:59:59";
  52. } else {
  53. continue;
  54. }
  55. }
  56. }
  57. return function ($query) use ($where, $start, $end) {
  58. if ($start) $where[] = ['created_at', '>=', $start];
  59. if ($end) $where[] = ['created_at', '<=', $end];
  60. if ($where) {
  61. $query->where($where);
  62. }
  63. };
  64. }
  65. /**
  66. * 数据更新
  67. */
  68. protected function _indexPost($datum)
  69. {
  70. foreach ($datum as $value){
  71. $value->{'name'}=$value->{'id'}==1?'用户端':'商户端';
  72. $value->{'type'}=$value->{'type'}==1?'比列':'固定金额';
  73. }
  74. return $datum;
  75. }
  76. }