mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
优化后台的标签和分类设置;优化后台头部菜单;
This commit is contained in:
@@ -145,52 +145,56 @@ class Post extends Common
|
|||||||
if (isset($post_data['categorys'])) {
|
if (isset($post_data['categorys'])) {
|
||||||
$categorys = $post_data['categorys'];
|
$categorys = $post_data['categorys'];
|
||||||
unset($post_data['categorys']);
|
unset($post_data['categorys']);
|
||||||
|
|
||||||
|
$old_category_list = PostCategory::where('post_id', $id)->select();
|
||||||
|
$old_category_id_list = array_column((array)$old_category_list, 'id');
|
||||||
|
|
||||||
|
// 旧的有新的没有
|
||||||
|
foreach ($old_category_list as $model_category) {
|
||||||
|
if (!in_array($model_category->id, $categorys)) {
|
||||||
|
$model_category->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 旧的没有新的有
|
||||||
|
foreach ($categorys as $category) {
|
||||||
|
if (!in_array($category, $old_category_id_list)) {
|
||||||
|
|
||||||
|
PostCategory::create([
|
||||||
|
'post_id' => $model_post->id,
|
||||||
|
'category_id' => $category
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($post_data['tags'])) {
|
if (isset($post_data['tags'])) {
|
||||||
$tags = $post_data['tags'];
|
$tags = $post_data['tags'];
|
||||||
unset($post_data['tags']);
|
unset($post_data['tags']);
|
||||||
|
|
||||||
|
$old_tag_list = PostTag::where('post_id', $id)->select();
|
||||||
|
$old_tag_id_list = array_column((array)$old_tag_list, 'id');
|
||||||
|
|
||||||
|
foreach ($old_tag_list as $model_tag) {
|
||||||
|
if (!in_array($model_tag->id, $tags)) {
|
||||||
|
$model_tag->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if (!in_array($tag, $old_tag_id_list)) {
|
||||||
|
|
||||||
|
PostTag::create([
|
||||||
|
'post_id' => $model_post->id,
|
||||||
|
'tag_id' => $tag
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$model_post->save($post_data);
|
$model_post->save($post_data);
|
||||||
|
|
||||||
$old_category_list = PostCategory::where('post_id', $id)->select();
|
|
||||||
$old_category_id_list = array_column((array)$old_category_list, 'id');
|
|
||||||
$old_tag_list = PostTag::where('post_id', $id)->select();
|
|
||||||
$old_tag_id_list = array_column((array)$old_tag_list, 'id');
|
|
||||||
|
|
||||||
// 旧的有新的没有
|
|
||||||
foreach ($old_category_list as $model_category) {
|
|
||||||
if (!in_array($model_category->id, $categorys)) {
|
|
||||||
$model_category->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($old_tag_list as $model_tag) {
|
|
||||||
if (!in_array($model_tag->id, $tags)) {
|
|
||||||
$model_tag->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 旧的没有新的有
|
|
||||||
foreach ($categorys as $category) {
|
|
||||||
if (!in_array($category, $old_category_id_list)) {
|
|
||||||
|
|
||||||
PostCategory::create([
|
|
||||||
'post_id' => $model_post->id,
|
|
||||||
'category_id' => $category
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
|
||||||
if (!in_array($tag, $old_tag_id_list)) {
|
|
||||||
|
|
||||||
PostTag::create([
|
|
||||||
'post_id' => $model_post->id,
|
|
||||||
'tag_id' => $tag
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->success('保存成功', url('index', ['type' => $model_post->getData('type')]));
|
return $this->success('保存成功', url('index', ['type' => $model_post->getData('type')]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
{if check_permission('file_list') }
|
{if check_permission('file_list') }
|
||||||
<li class="layui-nav-item header-nav-item" data-name="File"><a href="{:url('admin/File/index')}">文件管理</a></li>
|
<li class="layui-nav-item header-nav-item" data-name="File"><a href="{:url('admin/File/index')}">文件管理</a></li>
|
||||||
{/if}
|
{/if}
|
||||||
<li class="layui-nav-item header-nav-item" data-name="Post-1"><a href="{:url('admin/Post/index')}">内容管理</a></li>
|
|
||||||
<li class="layui-nav-item header-nav-item" data-name="Post-3"><a
|
<li class="layui-nav-item header-nav-item" data-name="Post-3"><a
|
||||||
href="{:url('admin/Post/index',['type'=>3])}">头条资讯管理</a></li>
|
href="{:url('admin/Post/index',['type'=>3])}">头条资讯管理</a></li>
|
||||||
<li class="layui-nav-item header-nav-item" data-name="Admin"><a href="{:url('admin/Admin/index')}">管理员管理</a></li>
|
<li class="layui-nav-item header-nav-item" data-name="Admin"><a href="{:url('admin/Admin/index')}">管理员管理</a></li>
|
||||||
|
|||||||
Reference in New Issue
Block a user