客户回收站
This commit is contained in:
@@ -116,7 +116,7 @@ class CustomerController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$recycle = Util::getParam('recycle', '');
|
$recycle = Util::getParam($request,'recycle', '');
|
||||||
if ($recycle == 'recycle') {
|
if ($recycle == 'recycle') {
|
||||||
$query->onlyTrashed();
|
$query->onlyTrashed();
|
||||||
}
|
}
|
||||||
@@ -138,11 +138,15 @@ class CustomerController
|
|||||||
*/
|
*/
|
||||||
public function restore(Request $request)
|
public function restore(Request $request)
|
||||||
{
|
{
|
||||||
$id = Util::getParam('id', '');
|
$id = Util::getParam($request,'id', '');
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
return Util::fail([], trans('id_empty'));
|
return Util::fail([], trans('id_empty'));
|
||||||
}
|
}
|
||||||
$where = ['id' => $id];
|
$userId = $request->user['id'];
|
||||||
|
$where = [
|
||||||
|
'id' => $id,
|
||||||
|
'user_id' => $userId,
|
||||||
|
];
|
||||||
$res = Customer::where($where)->restore();
|
$res = Customer::where($where)->restore();
|
||||||
if($res){
|
if($res){
|
||||||
return Util::success($res, trans('success'));
|
return Util::success($res, trans('success'));
|
||||||
@@ -301,8 +305,22 @@ class CustomerController
|
|||||||
public function delete(Request $request)
|
public function delete(Request $request)
|
||||||
{
|
{
|
||||||
$id = Util::getParam($request, 'id');
|
$id = Util::getParam($request, 'id');
|
||||||
$customer = Customer::where('id', $id)->first();
|
$force = Util::getParam($request, 'force','');
|
||||||
$res = $customer->delete();
|
|
||||||
|
$userId = $request->user['id'];
|
||||||
|
$where = [
|
||||||
|
'id' => $id,
|
||||||
|
'user_id' => $userId,
|
||||||
|
];
|
||||||
|
$customer = Customer::where($where)->withTrashed()->first();
|
||||||
|
if(empty($customer)){
|
||||||
|
return Util::fail('', trans('fail'));
|
||||||
|
}
|
||||||
|
if($force == 'force'){
|
||||||
|
$res = $customer->forceDelete();
|
||||||
|
}else{
|
||||||
|
$res = $customer->delete();
|
||||||
|
}
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('success'));
|
return Util::success($res, trans('success'));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ return [
|
|||||||
'email_consistent' => ' Inconsistent email addresses',
|
'email_consistent' => ' Inconsistent email addresses',
|
||||||
'sign_not_null' => ' No affiliated company has been set',
|
'sign_not_null' => ' No affiliated company has been set',
|
||||||
'password_short' => ' Password cannot be less than 6 characters',
|
'password_short' => ' Password cannot be less than 6 characters',
|
||||||
|
'id_empty' => ' ID cannot be empty',
|
||||||
];
|
];
|
||||||
@@ -26,4 +26,5 @@ return [
|
|||||||
'email_consistent' => ' 邮箱不一致',
|
'email_consistent' => ' 邮箱不一致',
|
||||||
'sign_not_null' => ' 未设置所属公司',
|
'sign_not_null' => ' 未设置所属公司',
|
||||||
'password_short' => ' 密码不能少于6位',
|
'password_short' => ' 密码不能少于6位',
|
||||||
|
'id_empty' => ' id不能为空',
|
||||||
];
|
];
|
||||||
Reference in New Issue
Block a user