|
|
|
@ -26,6 +26,7 @@ class SupplierController extends AdminController |
|
|
|
{ |
|
|
|
return Grid::make(new Supplier(), function (Grid $grid) { |
|
|
|
$grid->disableDeleteButton(); |
|
|
|
$grid->disableRowSelector(); |
|
|
|
|
|
|
|
//如果是审核页面,多加where条件判断
|
|
|
|
if (strpos(Route::current()->uri, 'audit')) { |
|
|
|
@ -180,6 +181,16 @@ class SupplierController extends AdminController |
|
|
|
DB::table(config('admin-supplier.database.role_users_table')) |
|
|
|
->insertOrIgnore(['role_id' => 2, 'user_id' => $form->getKey()]); |
|
|
|
} |
|
|
|
})->deleting(function (Form $form) { |
|
|
|
//禁止批量删除
|
|
|
|
if (strpos($form->getKey(), ',')) { |
|
|
|
return $form->response()->error('操作禁止'); |
|
|
|
} |
|
|
|
|
|
|
|
//禁止删除已发布有产品的供应商
|
|
|
|
if (Product::where('supplier_id', $form->getKey())->exists()) { |
|
|
|
return $form->response()->error('该供应商已发布有产品,禁止删除'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |