12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace App\Http\Controllers\GrantPond;
- use App\Http\Controllers\AdminBaseController;
- use App\Http\Requests\GrantPondCreateRequest;
- use App\Http\Requests\GrantPondUpdateRequest;
- use App\Repositories\Eloquent\GrantPondRepositoryEloquent;
- use App\Validators\GrantPondValidator;
- /**
- * Class GrantPondsController.
- *
- * @package namespace App\Http\Controllers;
- */
- class GrantPondsController extends AdminBaseController
- {
- /**
- * @var GrantPondRepositoryEloquent
- */
- protected $repository;
- /**
- * @var GrantPondValidator
- */
- protected $validator;
- /**
- * GrantPondsController constructor.
- *
- * @param GrantPondRepositoryEloquent $repository
- * @param GrantPondValidator $validator
- */
- public function __construct(GrantPondRepositoryEloquent $repository, GrantPondValidator $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)
- {
- return $datum;
- }
- }
|