|
|
|
@ -32,7 +32,7 @@ class ProductController extends AdminController |
|
|
|
return Grid::make(new Product(['category:id,name']), function (Grid $grid) { |
|
|
|
$type = request()->input('type'); |
|
|
|
|
|
|
|
if (isset($type) && isset(admin_trans('product.options.public_type')[$type])) { |
|
|
|
if (isset($type) && isset(admin_trans('product.options.publish_type')[$type])) { |
|
|
|
$grid->model()->where(['supplier_id' => Admin::user()->id, 'type' => $type]); |
|
|
|
$create_url = $grid->resource() . '/create?type=' . $type; |
|
|
|
Admin::script('$(function(){ $(".pull-right a").attr("href", "' . $create_url . '"); });'); |
|
|
|
@ -112,7 +112,7 @@ class ProductController extends AdminController |
|
|
|
*/ |
|
|
|
protected function form() |
|
|
|
{ |
|
|
|
Admin::user()->public_type = json_decode(Admin::user()->public_type, true); |
|
|
|
Admin::user()->publish_type = json_decode(Admin::user()->publish_type, true); |
|
|
|
return Form::make(new Product(), function (Form $form) { |
|
|
|
//不允许编辑非自己数据
|
|
|
|
if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) { |
|
|
|
@ -124,7 +124,7 @@ class ProductController extends AdminController |
|
|
|
if ($type == null) { |
|
|
|
Admin::exit('请选择要发布的产品类型'); |
|
|
|
} |
|
|
|
if (!Admin::user()->public_type || !in_array($type, Admin::user()->public_type)) { |
|
|
|
if (!Admin::user()->publish_type || !in_array($type, Admin::user()->publish_type)) { |
|
|
|
Admin::exit('对不起,你没有此类产品的发布权限'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -191,7 +191,7 @@ class ProductController extends AdminController |
|
|
|
} |
|
|
|
|
|
|
|
$type = $form->isCreating() ? $form->type : $form->model()->type; |
|
|
|
if (!Admin::user()->public_type || !in_array($type, Admin::user()->public_type)) { |
|
|
|
if (!Admin::user()->publish_type || !in_array($type, Admin::user()->publish_type)) { |
|
|
|
return $form->response()->error('对不起,你没有此类产品的发布、编辑权限'); |
|
|
|
} |
|
|
|
|
|
|
|
|