'=', 'type' => '=', 'sn' => 'like', 'name' => 'like', 'carrier_operator' => '=', ]; public function model() { return Model::class; } /** * 数据格式化 * * @param mixed $result * * @return mixed */ public function transform($model) { return $model->toArray(); } /** * 查询条件 * * @return void */ public function withConditions(array $conditions = []) { if (isset($conditions['id'])) { $conditions['id'] = array_wrap($conditions['id']); $this->model = $this->model->whereIn('id', $conditions['id']); } if (isset($conditions['type'])) { $this->model = $this->model->where('type', $conditions['type']); } if (isset($conditions['sn'])) { $this->model = $this->model->where('sn', "%{$conditions['sn']}%"); } if (isset($conditions['name'])) { $this->model = $this->model->where('name', "%{$conditions['name']}%"); } if (isset($conditions['carrier_operator'])) { $this->model = $this->model->where('carrier_operator', $conditions['carrier_operator']); } return $this; } }