'article_category', 'name' => '文章分类', 'list' => [ 'examples'=>'案例', 'services' =>'服务', 'news'=> '资讯动态' ]], // ['key' => 'article_tag', 'name' => '文章标签', 'list' => [//标签value填写色号,指定标签颜色 // ]], ['key' => 'banner_address', 'name' => '广告位置', 'list' => [ 'index-top'=>'首页', 'service-top' =>'服务项目', 'examples-top'=> '案例展示', 'companny-top'=>'公司介绍','contactus-top'=>'联系我们','news-top'=>'资讯动态' ]], ]; 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); } } } }