|
@@ -30,6 +30,39 @@ use Mockery\Exception;
|
|
*/
|
|
*/
|
|
class EmployeeService extends Service
|
|
class EmployeeService extends Service
|
|
{
|
|
{
|
|
|
|
+ public function employeeEditOther($data,$user){
|
|
|
|
+ list($status,$msg) = $this->employeeOtherRule($data,$user);
|
|
|
|
+ if(!$status) return [$status,$msg];
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
+ $model = new Employee();
|
|
|
|
+ $model = $model->where('id',$data['id'])->first();
|
|
|
|
+ $model->password = Hash::make($data['new_password']);
|
|
|
|
+ $model->save();
|
|
|
|
+
|
|
|
|
+ DB::commit();
|
|
|
|
+ }catch (\Exception $exception){
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ return [false, $exception->getMessage()];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return [true,''];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function employeeOtherRule($data,$user){
|
|
|
|
+ if(! isset($data['old_password'])) return [false,'请输入原密码'];
|
|
|
|
+ if($data['old_password'] == "") return [false,'原密码不能为空'];
|
|
|
|
+ if(! isset($data['new_password'])) return [false,'请输入新密码'];
|
|
|
|
+ if($data['new_password'] == "") return [false,'新密码不能为空'];
|
|
|
|
+ if(! isset($data['re_password'])) return [false,'请输入确认密码'];
|
|
|
|
+ if($data['re_password'] == "") return [false,'确认密码不能为空'];
|
|
|
|
+ if(! Hash::check($data['old_password'], $user['password'])) return [false,'原密码错误'];
|
|
|
|
+ if($data['new_password'] !== $data['old_password']) return [false,'新密码与确认密码不一致'];
|
|
|
|
+
|
|
|
|
+ return [true,''];
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 用户编辑
|
|
* 用户编辑
|
|
* @param $data
|
|
* @param $data
|