1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Http\Controllers\WithdrawConfig;
- use App\Http\Controllers\AdminBaseController;
- use App\Http\Requests\WithdrawConfigCreateRequest;
- use App\Http\Requests\WithdrawConfigUpdateRequest;
- use App\Repositories\Eloquent\WithdrawConfigRepositoryEloquent;
- use App\Validators\WithdrawConfigValidator;
- /**
- * Class WithdrawConfigsController.
- *
- * @package namespace App\Http\Controllers;
- */
- class WithdrawConfigsController extends AdminBaseController
- {
- /**
- * @var WithdrawConfigRepositoryEloquent
- */
- protected $repository;
- /**
- * @var WithdrawConfigValidator
- */
- protected $validator;
- /**
- * WithdrawConfigsController constructor.
- *
- * @param WithdrawConfigRepositoryEloquent $repository
- * @param WithdrawConfigValidator $validator
- */
- public function __construct(WithdrawConfigRepositoryEloquent $repository, WithdrawConfigValidator $validator)
- {
- parent::__construct($repository, $validator);
- }
- /**
- * 数据检索
- */
- public function _indexScopeQuery()
- {
- $where = [];
- $search = explode(";", request()->input('search', ""));
- $start = $end = null;
- $fieldSearchable=$this->repository->getFieldsSearchable();
- foreach ($search as $value) {
- if (!empty($value)) {
- list($one, $tow) = explode(":", $value);
- if (!empty($fieldSearchable[$one])) {
- if($fieldSearchable[$one]=='like')$tow="%{$tow}%";
- $where[]=[$one,$fieldSearchable[$one],$tow];
- } elseif ($one == 'start') {
- $start = $tow . " 00:00:00";
- } elseif ($one == 'end') {
- $end = $tow . " 23:59:59";
- } else {
- continue;
- }
- }
- }
- return function ($query) use ($where, $start, $end) {
- if ($start) $where[] = ['created_at', '>=', $start];
- if ($end) $where[] = ['created_at', '<=', $end];
- if ($where) {
- $query->where($where);
- }
- };
- }
- /**
- * 数据更新
- */
- protected function _indexPost($datum)
- {
- foreach ($datum as $value){
- $value->{'name'}=$value->{'id'}==1?'用户端':'商户端';
- $value->{'type'}=$value->{'type'}==1?'比列':'固定金额';
- }
- return $datum;
- }
- }
|