'article_category', 'name' => '文章分类', 'list' => [ // 'news'=> '企业资讯', 'honors'=>'资质荣誉', // ]], ['key' => 'banner_address', 'name' => '广告位置', 'list' => [ 'index-top'=>'首页', 'companny-top' =>'关于我们', 'project-top'=>'业务范围', 'examples-top'=> '案例展示', 'news-top'=>'资讯动态','contactus-top'=>'联系我们' ]], ['key' => 'honors', 'name' => '资质荣誉', 'list' => [ 'honor1'=>'核心资质认证', 'honor2'=>'管理体系认证','honor3'=>'重要荣誉奖项' ]], ['key' => 'case_study_tag', 'name' => '服务案例标签', 'list' => [//标签value填写色号,指定标签颜色 'case_study_tag1'=>'全项目保洁', 'case_study_tag2'=>'专项四害消杀消毒', 'case_study_tag3'=>'石材养护', 'case_study_tag4'=>'生活垃圾清运', 'case_study_tag5'=>'高端文旅项目保洁', 'case_study_tag6'=>'海域水上垃圾清理清运' ]], ]; foreach ($list as $item) { $type = Keyword::create(Arr::except($item, 'list')); if (isset($item['list'])) { $keywords = []; foreach ($item['list'] as $index => $name) { if(is_string($index)){ $_key = $index; }else{ $_key = $type->key. ($index + 1); } $template = [ 'key' => $_key, 'parent_key' => $type->key, 'lv' => $type->lv + 1, ]; if (is_array($name)) { $template = array_merge($template, $name); } else { $template['name'] = $name; } array_push($keywords, $template); } $type->children()->createMany($keywords); } } } }