|
|
|
@ -201,21 +201,21 @@ class User extends BaseController |
|
|
|
|
*/ |
|
|
|
|
public function update($id, UserValidate $validate, UserLabelRepository $labelRepository, UserGroupRepository $groupRepository) |
|
|
|
|
{ |
|
|
|
|
$data = $this->request->params(['real_name', 'phone', 'birthday', 'card_id', 'addres', 'mark', 'group_id', ['label_id', []], ['is_promoter', 0], ['status', 0]]); |
|
|
|
|
$data = $this->request->params(['real_name', 'phone', 'birthday', 'card_id', 'addres', 'mark']); |
|
|
|
|
$validate->check($data); |
|
|
|
|
if (!$this->repository->exists($id)) |
|
|
|
|
return app('json')->fail('数据不存在'); |
|
|
|
|
if ($data['group_id'] && !$groupRepository->exists($data['group_id'])) |
|
|
|
|
return app('json')->fail('分组不存在'); |
|
|
|
|
$label_id = (array)$data['label_id']; |
|
|
|
|
foreach ($label_id as $k => $value) { |
|
|
|
|
$label_id[$k] = (int)$value; |
|
|
|
|
if (!$labelRepository->exists((int)$value)) |
|
|
|
|
return app('json')->fail('标签不存在'); |
|
|
|
|
} |
|
|
|
|
$data['label_id'] = implode(',', $label_id); |
|
|
|
|
if ($data['is_promoter']) |
|
|
|
|
$data['promoter_time'] = date('Y-m-d H:i:s'); |
|
|
|
|
// if ($data['group_id'] && !$groupRepository->exists($data['group_id'])) |
|
|
|
|
// return app('json')->fail('分组不存在'); |
|
|
|
|
// $label_id = (array)$data['label_id']; |
|
|
|
|
// foreach ($label_id as $k => $value) { |
|
|
|
|
// $label_id[$k] = (int)$value; |
|
|
|
|
// if (!$labelRepository->exists((int)$value)) |
|
|
|
|
// return app('json')->fail('标签不存在'); |
|
|
|
|
// } |
|
|
|
|
// $data['label_id'] = implode(',', $label_id); |
|
|
|
|
// if ($data['is_promoter']) |
|
|
|
|
// $data['promoter_time'] = date('Y-m-d H:i:s'); |
|
|
|
|
if(!$data['birthday']) unset($data['birthday']); |
|
|
|
|
$this->repository->update($id, $data); |
|
|
|
|
|
|
|
|
|