1 | <?php |
||
2 | |||
3 | namespace Conner\Tagging\Console\Commands; |
||
4 | |||
5 | use Conner\Tagging\TaggingUtility; |
||
6 | use Conner\Tagging\Model\TagGroup; |
||
7 | use Illuminate\Console\Command; |
||
8 | use Symfony\Component\Console\Input\InputArgument; |
||
9 | |||
10 | class GenerateTagGroup extends Command |
||
11 | { |
||
12 | protected $name = 'tagging:create-group'; |
||
13 | |||
14 | protected $signature = 'tagging:create-group {group}'; |
||
15 | |||
16 | protected $description = 'Create a laravel tag group'; |
||
17 | |||
18 | public function handle() |
||
19 | { |
||
20 | $groupName = $this->argument('group'); |
||
21 | |||
22 | $tagGroup = new TagGroup(); |
||
23 | $tagGroup->name = $groupName; |
||
24 | $tagGroup->slug = TaggingUtility::normalize($groupName); |
||
25 | |||
26 | $tagGroup->save(); |
||
27 | |||
28 | $this->info('Created tag group: '.$groupName); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
29 | } |
||
30 | |||
31 | protected function getArguments() |
||
32 | { |
||
33 | return [ |
||
34 | ['group', InputArgument::REQUIRED, 'Name of the group to create.'], |
||
35 | ]; |
||
36 | } |
||
37 | } |
||
38 |