'商品', 'menu' => '菜单', 'permission' => '权限', 'role' => '角色', 'user' => '用户', ]; return $map[$value]; } public function getActionAttribute($value) { $map = [ 'GET' => '查看', 'POST' => '新增', 'PATCH' => '更新', 'DELETE' => '删除', ]; return $map[$value]; } public function getTargetTypeAttribute($value) { $map = [ 'goods_sku' => '商品&规格', 'goods_type' => '商品种类', 'goods_brand' => '商品品牌', 'permission' => '权限', 'role' => '角色', 'menu' => '菜单', 'user' => '用户', ]; return $map[$value]; } public function getTargetFieldAttribute($value) { $map = [ 'add' => '创建', 'status' => '状态', 'name' => '名称', 'title' => '名称', 'import' => '导入', 'export' => '导出', 'set' => '设置', ]; return $map[$value]; } public function setUserIdAttribute($value) { $this->attributes['user_id'] = Auth::id(); } public function add($targetId = 0, $targetField = '') { $this->attributes['user_id'] = Auth::id(); $this->attributes['target_id'] = $targetId; $this->attributes['target_field'] = $targetField; return $this->save(); } }