|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Console\Commands; |
| 4 | + |
| 5 | +use App\Constants\BoardListsKeys; |
| 6 | +use App\Constants\LabelKeys; |
| 7 | +use App\Constants\TeamKeys; |
| 8 | +use App\Models\BoardList; |
| 9 | +use App\Models\Label; |
| 10 | +use App\Models\Team; |
| 11 | +use Illuminate\Console\Command; |
| 12 | + |
| 13 | +class SetupManagementWorkspace extends Command |
| 14 | +{ |
| 15 | + /** |
| 16 | + * The name and signature of the console command. |
| 17 | + * |
| 18 | + * @var string |
| 19 | + */ |
| 20 | + protected $signature = 'setup:management-workspace'; |
| 21 | + |
| 22 | + /** |
| 23 | + * The console command description. |
| 24 | + * |
| 25 | + * @var string |
| 26 | + */ |
| 27 | + protected $description = '[Temporário] Configura workspace para o time de gestão'; |
| 28 | + |
| 29 | + /** |
| 30 | + * Create a new command instance. |
| 31 | + * |
| 32 | + * @return void |
| 33 | + */ |
| 34 | + public function __construct() |
| 35 | + { |
| 36 | + parent::__construct(); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * Execute the console command. |
| 41 | + * |
| 42 | + * @return mixed |
| 43 | + */ |
| 44 | + public function handle() |
| 45 | + { |
| 46 | + $this->info('Iniciando...'); |
| 47 | + $this->createLabels(); |
| 48 | + $this->createTeams(); |
| 49 | + $this->createSprintBoardLists(); |
| 50 | + $this->createDoingBoardList(); |
| 51 | + $this->info('Tudo pronto!'); |
| 52 | + } |
| 53 | + |
| 54 | + private function createLabels() |
| 55 | + { |
| 56 | + $managementLabels = [ |
| 57 | + [ |
| 58 | + 'name' => 'Gente e Gestão', |
| 59 | + 'key' => LabelKeys::PM, |
| 60 | + 'color' => '#815AA5', |
| 61 | + 'text_color' => '#fff', |
| 62 | + ], |
| 63 | + [ |
| 64 | + 'name' => 'Financeiro', |
| 65 | + 'key' => LabelKeys::FINANCIAL, |
| 66 | + 'color' => '#028D29', |
| 67 | + 'text_color' => '#fff', |
| 68 | + ], |
| 69 | + [ |
| 70 | + 'name' => 'Comunicação', |
| 71 | + 'key' => LabelKeys::COMUNICATION, |
| 72 | + 'color' => '#FFAA2B', |
| 73 | + 'text_color' => 'rgba(0, 0, 0, 0.75)', |
| 74 | + ], |
| 75 | + |
| 76 | + [ |
| 77 | + 'name' => 'Comercial', |
| 78 | + 'key' => LabelKeys::SALES, |
| 79 | + 'color' => '#3171A3', |
| 80 | + 'text_color' => '#fff', |
| 81 | + ], |
| 82 | + [ |
| 83 | + 'name' => 'Projetos', |
| 84 | + 'key' => LabelKeys::PROJECTS, |
| 85 | + 'color' => '#54EF1A', |
| 86 | + 'text_color' => 'rgba(0, 0, 0, 0.75)', |
| 87 | + ], |
| 88 | + [ |
| 89 | + 'name' => 'Reunião', |
| 90 | + 'key' => LabelKeys::MEET, |
| 91 | + 'color' => '#EC6646', |
| 92 | + 'text_color' => '#fff', |
| 93 | + ], |
| 94 | + [ |
| 95 | + 'name' => 'Gestão de cidades', |
| 96 | + 'key' => LabelKeys::CITY_MANAGEMENT, |
| 97 | + 'color' => '#97D480', |
| 98 | + 'text_color' => 'rgba(0, 0, 0, 0.75)', |
| 99 | + ], |
| 100 | + |
| 101 | + [ |
| 102 | + 'name' => 'Produto', |
| 103 | + 'key' => LabelKeys::PRODUCT, |
| 104 | + 'color' => '#21222E', |
| 105 | + 'text_color' => '#fff', |
| 106 | + ], |
| 107 | + ]; |
| 108 | + |
| 109 | + $this->info('Criando labels...'); |
| 110 | + |
| 111 | + |
| 112 | + $value = Label::insert($managementLabels); |
| 113 | + |
| 114 | + if ($value) { |
| 115 | + $this->info('Labels inseridas com sucesso'); |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + private function createTeams() |
| 120 | + { |
| 121 | + $teams = [ |
| 122 | + [ |
| 123 | + 'name' => 'SysIN', |
| 124 | + 'key' => TeamKeys::SYS_IN, |
| 125 | + 'short_task_flow' => true, |
| 126 | + ], |
| 127 | + [ |
| 128 | + 'name' => 'SysOUT', |
| 129 | + 'key' => TeamKeys::SYS_OUT, |
| 130 | + 'short_task_flow' => true, |
| 131 | + ], |
| 132 | + ]; |
| 133 | + |
| 134 | + $this->info('Criando times...'); |
| 135 | + |
| 136 | + $value = Team::insert($teams); |
| 137 | + |
| 138 | + if ($value) { |
| 139 | + $this->info('Times inseridos com sucesso'); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + private function createDoingBoardList() |
| 144 | + { |
| 145 | + $this->info('Criando doing board list...'); |
| 146 | + |
| 147 | + $value = BoardList::create([ |
| 148 | + 'name' => 'Doing', |
| 149 | + 'key' => BoardListsKeys::DOING, |
| 150 | + 'position' => 1, |
| 151 | + ]); |
| 152 | + |
| 153 | + if ($value) { |
| 154 | + $this->info('Doing board list criado com sucesso'); |
| 155 | + } |
| 156 | + } |
| 157 | + |
| 158 | + private function createSprintBoardLists() |
| 159 | + { |
| 160 | + $teams = Team::all(); |
| 161 | + |
| 162 | + $this->info('Criando sprint board lists...'); |
| 163 | + |
| 164 | + $teams->each(function ($team) { |
| 165 | + $board_list = BoardList::where('key', $team->key)->count(); |
| 166 | + if ($board_list === 0) { |
| 167 | + $value = BoardList::create([ |
| 168 | + 'name' => 'Sprint - '. $team->name, |
| 169 | + 'key' => $team->key, |
| 170 | + 'user_story_holder' => true, |
| 171 | + 'position' => 3, |
| 172 | + ]); |
| 173 | + |
| 174 | + if ($value) { |
| 175 | + $this->info('Lista criada com sucesso...'); |
| 176 | + } |
| 177 | + } |
| 178 | + }); |
| 179 | + } |
| 180 | +} |
0 commit comments